From: ts Date: 2001-12-07T00:59:19+09:00 Subject: [ruby-talk:27705] Re: Emulating multimethods >>>>> "C" == Christopher S Kush writes: C> I'm familiar with State and Visitor patterns, but I really want C> multi-methods. There are problems on multi-methods. Just an example with this case class A < Array end class B def b(A a) puts "A" next_method end def b(Array a) puts "Array" end end B.new.b(A.new) If you expect the output A Array like it must be done with multi-methods then you have introduced a new rule in ruby. This rule say that to find the right call, ruby choose the "best" call by comparing the class of the arguments with the classes given in the prototype. Unfortunately you have a similar case already in ruby and this is this case class A < Array end a = Array.new b = A.new p ((a + b).class) ruby is in a similar situation and if it use the rule given by the multi-methods, the result must be A. But ruby has made another choice, and actually the result is Array. These 2 choices are valids (and incompatible) but the choice made by ruby (base class) is *easier* to understand rather than the *complex* choice made by multi-methods. Trying to introduce multi-methods in ruby is like trying to introduce a new rule which conflict with an (valid and easy to understand) existent rule Guy Decoux