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

Re: Multiple-dispatch on functions

Thread Previous | Thread Next
From:
Dan Sugalski
Date:
September 1, 2001 12:13
Subject:
Re: Multiple-dispatch on functions
Message ID:
5.1.0.14.0.20010901151002.01fa4f98@tuatha.sidhe.org
At 03:06 PM 9/1/2001 -0400, Michael G Schwern wrote:
>On Sat, Sep 01, 2001 at 01:10:58PM -0400, Dan Sugalski wrote:
> > At 10:03 PM 8/30/2001 -0400, Michael G Schwern wrote:
> > >Thinking about what Zhang was saying about multiple-dispatch not being
> > >inherently OO.  I think he's sort of right.  Multiple-dispatch need
> > >not be confined to method lookups.
> >
> > There is the potential for a pretty significant cost to this, since we'd
> > need to evaluate the args at runtime for each call. (Possibly we could do
> > some compile time optimization, but not in a lot of places, alas)
>
>Hmmmm.... shouldn't be any worse than a multi-method call.  And it'll
>only effect those functions with the 'multi' flag.

Nope, the cost will be paid on all sub calls. We at least need to check on 
every sub call to see if there are multiple versions of the functions. (We 
can't tell at compile time if it's a single or multi-method sub call, since 
it can change at runtime) Granted, it's not a huge expense for 
non-multi-method calls, but it does still impose an overhead everywhere.

					Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
dan@sidhe.org                         have teddy bears and even
                                      teddy bears get drunk


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