If I write:
sub foo( Int $a, Int $b ) {...}
sub foo( Int $a, Int $c ) { print $a+$c }
Are these now equivalent:
foo( a => 1, b => 2 )
foo( a => 1, c => 3 )
What if I wrote:
sub bar( Int $a, Num $b ) {...}
sub bar( Int $b, Num $a ) { print $a - $b }
bar( a => 1, b => 3 )
Hopefully this is an error!
Can I discriminate on parameter names using multi subs?
multi sub alu( $num, $add is required_named) { print $num + $add}
multi sub alu( $num, $sub is required_named) { print $num - $sub }
alu( 5, add=>4 ); # prints "9"
alu( 5, sub=>4 ); # prints "1"
Dave.
Nope. Named parameters don't participate in MMD.
--
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk
1. I'm thinking MMD should be called something else when being applied
to multisubs rather than multimethods . . .
2. If named parameters are not part of the subroutine's "signature"
for selection purposes, that is perhaps an argument for not allowing
them to be mandatory (which I asked about earlier).
-Mark