In article <m2d7eamv3o.fsf / zip.local.thomases.com>, Dave Thomas <Dave / PragmaticProgrammer.com> wrote: >jstern / foshay.citilink.com (Josh Stern) writes: > >> Yukihiro Matsumoto <matz / zetabits.com> wrote: >> >> >I'd add method overloading according their dynamic type of arguments, >> >iff I can think of a specification which is affordable and consistent >> >with rest of Ruby. But I have little hope about this issue. >> >> Well, just to throw something out there...perhaps there could be a >> rule that methods with a special name, e.g. ending with the '|' >> character, are actually looked up based on hashing the method name >> plus the argument type ids? > >It'd have to be a fairly clever hash, as you'd have to be able to deal >with subclasses. Put another way: if one actually wanted it to have a behavior similar to, say, Koenig lookup in C++, that would be quite slow to do dynamically at run time, since the interpreter would have to keep trying new hashes as it ascended the hierarchy. But that expense would only apply to somebody using it in that way, and there would be a pretty obvious optimization to fix it (overload again for the dynamic type you care about). >Tell me again: what problem are we trying to solve here? You mean why would somebody want to overload a method on arg types rather than manually do their own dispatch for different arguments in one method (not very encapsulated) or create different methods that abort if called with the wrong arguments? It seems like the interpreter could help a bit with keeping things straight. If it turned out that it didn't hurt other things (big 'If') then it seems like it would be a good feature. -= Josh