Sartak sartak-at-gmail.com |Perl 6| wrote:
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).

The dispatcher isn't associated with an ultimate base class. I think the bases are in fact independant from the dispatcher chosen for a concrete class. Your wierdo class will still inherit from Object or whatever it's called.
The metaobject is pointed to by the HOW.



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.
I see. Except for accessing the method accessor HOW. But I think you are agreeing with my point. I've thought about the details, but the Moose folks have it all figured out, they tell me.

IAC, Installing the dispatcher is done by setting up the object that lives at $object.HOW. That process gets kicked off when the parser determines a method call is needed, and differing dispatchers don't bother that process at all. It has nothing to do with changing what the dot performs when it is found by the parser.




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


Reply via email to