Dan Sugalski wrote:
> 
> At 2:06 PM +0000 2/19/03, Peter Haworth wrote:
> >On Fri, 14 Feb 2003 15:56:25 -0500, Dan Sugalski wrote:
> >>  I got clarification. The sequence is:
> >>
> >>  1) Search for method of the matching name in inheritance tree
> >>  2) if #1 fails, search for an AUTOLOAD
> >>  3) if #2 fails (or all AUTOLOADs give up) then do MM dispatch
> >
> >Shouldn't we be traversing the inheritance tree once, doing these
> >three steps at each node until one works, rather doing each step once
> >for the whole tree. MM dispatch probably complicates this, though.
> 
> No, you have to do it multiple times. AUTOLOAD is a last-chance
> fallback, so it ought not be called until all other chances have
> failed.
> 
> >If my derived class has an autoloaded method which overrides the base
> >class' method, I don't want the base class method to be called, just
> >because parrot does things in a peculiar order. Well, I know it's the
> >same order that perl5 does things, but it's still peculiar.
> 
> If you prototype the sub but AUTOLOAD the body it'll work OK.

<newbie to perl6; I've just joined this mailing list>

How about two AUTO subroutines?  An AUTOPROTO method, which will return
the prototype of the subroutine being looked for.  If it returns undef,
then we know to keep looking up the inheritance tree.  If it doesn't
return undef, cache the prototype (just as if someone had created a stub
for that subroutine with that prototype), and then call AUTOLOAD.

There are a number of benefits of doing it this way:
   1/ Just a single traversal of the inheritance tree.
   2/ More than one class can have an AUTOLOAD.
   2a/ No need for $self->NEXT::AUTOLOAD(@_)
   3/ If perl6 allows $coderef = someclass.can('somemethod'), similar
      to perl5's UNIVERSAL::can, then this will work right even if
      somemethod *would* be autoloaded, but hasn't been created yet,
      or if the AUTOLOAD method chooses not to cache a subroutine for
      it.   (.can would would search the inheritance tree (once), and
      call AUTOPROTO as needed, but would not call AUTOLOAD)

Item (2) is perhaps the most important, since none of the other things
in this thread seem to address it.

</newbie>


-- 
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print

Reply via email to