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

Multiple-dispatch on functions

Thread Next
From:
Michael G Schwern
Date:
August 30, 2001 19:03
Subject:
Multiple-dispatch on functions
Message ID:
20010830220354.B6116@blackrider
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.

    foo();
    foo($bar);
    foo($baz);
    foo($bar, $baz);

    sub foo () : multi {
        ...
    }

    sub foo (Bar $bar) : multi {
        ...
    }

    sub foo (Baz $baz) : multi {
        ...
    }

    ...etc...

Obviously, there would be no inheritance.  Otherwise, it's
just like multiple-dispatch where there's no superclass.

Handy, if it's not too hard to implement.


-- 

Michael G. Schwern   <schwern@pobox.com>    http://www.pobox.com/~schwern/
Perl6 Quality Assurance     <perl-qa@perl.org>	     Kwalitee Is Job One
"Let's face it," said bearded Rusty Simmons, opening a can after the
race.  "This is a good excuse to drink some beer."  At 10:30 in the
morning?  "Well, it's past noon in Dublin," said teammate Mike
[Joseph] Schwern.  "It's our duty."
    -- "Sure, and It's a Great Day for Irish Runners" 
       Newsday, Sunday, March 20, 1988

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