On 22/12/2009 10:22, Moritz Lenz wrote:
Carl MXXsak (via RT) wrote:
This be Rakudo 8dc189.

$ perl6 -e 'multi sub f($a) {}; multi sub f($a) {}; f(42)'
Ambiguous dispatch to multi 'f'. Ambiguous candidates had signatures:
:(Any $a)
:(Any $a)

The definition of two variants with equivalent signatures (i.e.
identical up to names) can, and IMHO should, be caught statically.
I've wondered about that too, and for multi methods it can make sense to
have two multis with the same signature, for example for usage with .+
and .*

Is there a way to call multiple multi subs?

.+ and .* will call all multi candidates as well as all the way up the hierarchy. I actually have written code that takes advantage of being able to do this - it's a cute way to handle simple pub/sub stuff.

Unless/until there is some excellent introspection into where clauses,
there are limits to the signature comparison that can be made, but at
least the simple cases should be no problem.
agreed.

Aye; the general problem is turing complete.

Jonathan

Reply via email to