From: "trans. (T. Onoma)" Date: 2005-01-14T05:50:30+09:00 Subject: Re: Duck Typing as Pattern Matching On Thursday 13 January 2005 01:06 pm, itsme213 wrote: | Not sure what "upon" is. If your intent is to associated distinct | method_missing handler procs with selectors, so that Object#respond_to? can | utilize this properly, it can be done in many ways. e.g. Object could | provide a register_method_missing_handler: | | class MyClass | register_method_missing_handler :selector, { |*args| handler } | end | | Then Object#respond_to? could utilize the registered selectors. | | One difficulty would be generic handlers (e.g. a proxy handles anything its | real target does, OpenStruct handles any x() and x(y)), so the "associated | selectors" would need to include something like pattern matching or | wildcards. Oh, oh, ... does that mean we are back to duck typing based on | pattern matching ? ;-) Of course ;) And that's why I used "upon" and not just a case statement or secondary "respond_if" method to invoke a method_missing handler. T. P.S. Of course the coolest of cool would be if Ruby were so reflectively powerful as to allow for true method probing. Then Ruby could simply probe #method_missing and determine if it responds. But of course, that's _so cool_ b/c in fact it may not even be possible.