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

Re: Multiple-dispatch on functions

Thread Previous | Thread Next
From:
Damian Conway
Date:
August 30, 2001 19:32
Subject:
Re: Multiple-dispatch on functions
Message ID:
200108310232.NAA84349@indy05.csse.monash.edu.au
   > 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.

True, but that doesn't make it non-OO ;-)


   >     foo();
   >     foo($bar);
   >     foo($baz);
   >     foo($bar, $baz);
   > 
   >     sub foo () : multi { ... }
   >     sub foo (Bar $bar) : multi { ... }
   >     sub foo (Baz $baz) : multi { ... }

Yes. Ordinary subroutine overloading (like that offered by C++)
certainly does fall out as a happy side-effect of multiple dispatch
in dynamic languages.

For example, see:

        http://dev.perl.org/rfc/256.html#Handling_built_in_types

But note that the *run-time* dispatch of these overloaded subroutines
is still critically important because of Perl's dynamic typing of values
within container data structures.

Damian

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