From: "Chr. Rippel" Date: 2001-12-31T22:22:00+09:00 Subject: [ruby-talk:29848] Re: extending method of class A to support arguments of class B by promoting `self' to class B "Tomasz Wegrzanowski" wrote > > Such-thing is defined more by problem it tries to solve than by solution. > > Not every relation can be put into "object-oriented" form, > where one of involved objects logically-dominates all others. > Often, relation involve more than one object at logically-equal-rights. > The most obvious example are mathematical relations, like addition and substraction, where none > of objects is logically-more-important than others. > It doesn't happen only in case of symmetrical relations - substraction is obviously asymmetrical, > but none of the objects dominates another. > Such-thing would allow one to provide rules of interaction on any side of relation. > Now, in most object-oriented-languages, including Ruby, > NewClass.relation(OldClass) is much easier to define than OldClass.relation(NewClass), > although their nature is alike. > I agree with your analysis that OO programming often forces an unnatural logical order of arguments on method with in principle perfectly (anti) symmetrical argument order (the most common example are the equal operators) and my guess is that many OO programming languages unconsciously try to accommodate this shortcoming. In C++ the friend mechanism and Ruby the coerce mechanism comes to mind and a well established OO-pattern ``solution'' is double dispatch. The most satisfying solution IMO is (anti-)symmetric multi-dispatch but there are very few actual implementation. The main reason that symmetric multi-dispatch did not caught on up to now is probably software momentum (which seems the only plausible explanation for Javas success - ironically there is an implementation by one of Authors of Self on top of Java). There were quite a few threads on this list on ordinary multi-dispatch the general consensus being that it does fit well with Ruby current Object model (which is true) so we probably will never see symmetric multi-dispatched methods in Ruby. /Christoph