[Pdx-pm] multi-method dispatch in rakudo

Eric Wilhelm scratchcomputing at gmail.com
Fri Sep 12 23:18:34 PDT 2008


  http://use.perl.org/~JonathanWorthington/journal/37430

(If you've been playing along, you can just start with:
  cd parrot ; svn up
)

  svn co https://svn.perl.org/parrot/trunk parrot
  cd parrot

  perl Configure.pl
  make perl6

  ./perl6 -e '
    multi sub foo(Int $x) { 1 }
    multi sub foo(Int $x where { $^n > 42 }) { 2 }
    say foo(12);
    say foo(45);'

  ./perl6 -e '
    role Explode { }
    class Firework does Explode { }
    class Kitten { }
    multi sub bar(Explode $x) { 1 }
    multi sub bar(Kitten $x) { 2 }
    say bar(Firework.new);
    say bar(Kitten.new);'

For those just joining us, 'class' is the new 'package' (well, unless it 
is a module.)

--Eric
-- 
Hot dogs:  just another condiment.
--Heart-attack Man
---------------------------------------------------
    http://scratchcomputing.com
---------------------------------------------------


More information about the Pdx-pm-list mailing list