From: Paul Brannan Date: 2002-09-14T00:43:26+09:00 Subject: Re: not grasping the method overloading/multi-dispatch thing On Fri, Sep 13, 2002 at 05:51:48PM +0900, Pit Capitain wrote: > Paul, in the former thread Robert Feldt showed another > implementation in [ruby-talk:26792] that lets you do what you > asked for. I came up with the following implementation based on > Robert's code. Don't know why I didn't post it to the list then. > Maybe because it still lacks some necessary features. > Definitely looks cool! Some issues (and "necessary features" that are lacking): 1) Passing a block to overload() means that you don't have access to instance variables (self isn't set properly when the block is called). Maybe it would be nifty if Ruby gave the user an interface to change a Proc's "self". 2) I don't like passing a string to class_eval. I think this could be implemented with define_method. 3) Ideally I should be able to pass a block to the method. 4) The dispatch method is O(n). I wish I had a good solution to this problem; iterating over all the ancestors of all the arguments is likely to be slower (a giant table of all possible signatures could be kept, if we had a callback for knowing when a class gets a new subclass). Paul