develooper Front page | perl.perl6.language | Postings from September 2001

Re: Multiple-dispatch on functions

Thread Previous | Thread Next
From:
Ken Fox
Date:
September 2, 2001 09:38
Subject:
Re: Multiple-dispatch on functions
Message ID:
3B926264.EB8B2C66@vulpes.com
Damian Conway wrote:
> Ken wrote:
>    > 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.

Oops. I meant "sugar for one implementation of dispatch."

We could eliminate single dispatch and *only* use multi-dispatch.
The ":multi" attribute would just turn off the default behavior of
replacing an existing function.

> The only internal difference is that the first version has to do the
> normal Perl single dispatch look-up before it discovers that

Right. What if there wasn't a single dispatcher?

I think multi dispatch could eliminate single dispatch if we looked
for function matches in the current lexical scope *and* in the @ISA
packages for every argument.

Multi-dispatch is just as fast as single dispatch if only a single
function matches. The compiler could easily keep track of this.

- Ken

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About