On Fri, May 22, 2009 at 7:52 PM, John M. Dlugosz <2nb81l...@sneakemail.com> wrote: > That sounds like a circular reference problem. If the dot is a simple multi > sub and is expected to dispatch based on type (different types may have > different dispatchers), what "type" are you keying off of to pick the > standard dispatcher? And how do you determine that without method calls?
I haven't been following Perl 6 design terribly closely, but I'll take a shot at these two questions from what I know about OO design. The standard dispatcher is associated with Perl 6's equivalent of Perl 5's UNIVERSAL (or CLOS's "t", Java's "java.lang.Object" or whatever, etc.). The superest superclass. A class would be able to say "no no, use this dispatcher instead", which would take effect for all of its descendents (unless they too override dispatching). There would be several behind-the-scenes method calls involved in calling $object.foo. The first would be $object.HOW to get the metaclass of $object. The metaclass would then perform many method calls on itself and its associated behind-the-scenes objects in order to dispatch the original method call of "foo" on $object. The metaclass's own method calls would not be affected, since the metaclass is (presumably) using the standard dispatch logic. Of course, metaclasses would be able to define their own dispatch logic. That would mean changing the metaclass's metaclass. Due to the layered and recursive nature of metaobject protocols, it should all just work. That's why MOPs are so nice. Again, I must stress that I don't actually know how Perl 6 chose to do this, but this is how it works in the MOP-empowered languages I've looked at closely. :) I'd be more than happy to be corrected by someone who knows how it does work. Shawn