Today I have done a couple more things on multiple dispatch in Perl 6. The major one is that
multi foo(Int $a, Num $b) { 1 }
multi foo(Num $a, Int $b) { 2 }
Will, when invoked as foo(1,1), give an ambiguous dispatch error, since neither of these subs is narrower than the other - they are tied. However, if you instead wrote:
multi foo(Int $a;; Num $b) { 1 }
multi foo(Num $a;; Int $b) { 2 }
Then foo(1,1) will call the first of these multis, since it only looks at the signatures so far as the
The more minor one is that multi, only and proto may only be used, according to the spec, on named routines, not anonymous ones. Rakudo now meets this bit of the spec (it will give a compile time error), and I've put in some spec tests to check this too.
And with these two additions, the grant from Deep Text draws to an end. I'll be posting a final report soon - thanks to Deep Text for funding this, and many other bits of, hacking on Rakudo's multiple dispatch!
;; works, making illegal things illegal 0 Comments More | Login | Reply /