In <[EMAIL PROTECTED]> Adam Turoff wrote:
> Damian just got finished his YAPC opening talk, and managed to allude
> to dispatching and autoloading.
> 
> As it *appears* today, regular dispatching and multimethod dispatching
> are going to be wired into the langauge (as appropriate).  Runtime
> dispatch behavior will continue to be supported, including things like
> AUTOLOADER and the like.
> 
> As of January, the thinking is sub DISPATCH {} will handle runtime
> dispatching behaviors, including autoloading, but easily accomodating
> value-based dispatching, AOP style pre/post methods, and whatnot.  
> 
> Unfortunately, Damian said that the design team isn't saying much 
> about this, because the semantics aren't quite worked out yet, 
> especially with the interaction between autoloading and other dynamic 
> dispatching behaviors.
>
> Yes, this is a *big* issue.

It definitely is.

I can't speak for Perl 6 the language, but I can speak for Parrot, so I 
can tell you what semantics will be available (though not necessarily 
exposed) to the compiler.

For methods, each object is ultimately responsible for deciding what to 
do when a method is called. Since objects generally share a class-wide 
vtable, the classes are mostly responsible for dispatch. The dispatch 
method can, if it wants, do *anything*. However, as some degree of 
predictability is nice, the current plan is that classes will:

  1) Look for the method in the class or parent. If found, it's 
dispatched to. (This method may be defined as a multimethod in the class, 
in which case MMD is used to determine which method of the set *in the 
class only* is used)
  2) Look for an AUTOLOAD method in the class or parent. If found, we 
dispatch to it.
  3) Look for a MMD version of the method outside of any class. If found, 
do MMD

Core engine support will be in for this, since we don't want everyone to 
have to bother writing code for it all. Duplicate code. Bleah. We'll 
also provide method caches so we have some hope of not being horribly 
slow.

By default, the system and class MMD will do class-based dispatching 
only, deciding on which method to call based on the types of the 
parameters. Both the class MMD method *and* the system MMD method may be 
overridden if someone wants to install their own MMD scheme, though 
overriding system-wide MMD stuff is always a dodgy thing. (Though no 
more than any other overridden systemwide thing, I expect)

Will perl 6 support this? Dunno. Will it call for a different scheme? It 
well might. Can a language completely skip the MMD stuff? It can if it 
chooses, yes. What name will the dispatch sub be? Beats the heck out of 
me, but then that's syntax and I don't do syntax. :)

Reply via email to