Ken wrote:
> The way to approach this problem is to profile
> Class::MultiMethods and figure out (a) where the hot spots
> are and (b) what core support would help eliminate those
> hot spots.
But please don't do that until I release the next update of C::MM,
which will use a new dispatch mechanism that is pluggable.
> The one thing I'm curious about is whether different syntactic
> conventions affect the dispatcher or whether this is all just
> sugar for a single dispatch.
Multiple dispatch is certainly not (practically) implementable via single
dispatch. Oh, there *are* techniques, but they're subject to exponential
blow-out in the number of intermediate methods required to resolve all
possible dispatches.
Syntactically, C::MM dispatches the call:
$obj1->multimethod($obj2, $obj3);
exactly the same as:
multimethod($obj1, $obj2, $obj3);
The only internal difference is that the first version has to do the
normal Perl single dispatch look-up before it discovers that
&multimethod is a multimethod (the second version doesn't), whilst the
second version requires that &multimethod be declared a multimethod in
the current scope (the first version doesn't).
Damian