Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Implicit parameter aliases

2 views
Skip to first unread message

Dave Whipp

unread,
Aug 5, 2003, 4:02:21 PM8/5/03
to perl6-l...@perl.org
Are parameter names part of the function signature? A6 defines "siglets",
which don't appear to include parameter names.

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.


Dan Sugalski

unread,
Aug 5, 2003, 4:10:46 PM8/5/03
to Dave Whipp, perl6-l...@perl.org
At 1:02 PM -0700 8/5/03, Dave Whipp wrote:
>Can I discriminate on parameter names using multi subs?

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

Mark J. Reed

unread,
Aug 5, 2003, 6:20:30 PM8/5/03
to perl6-l...@perl.org
On 2003-08-05 at 16:10:46, Dan Sugalski wrote:
> At 1:02 PM -0700 8/5/03, Dave Whipp wrote:
> >Can I discriminate on parameter names using multi subs?
>
> Nope. Named parameters don't participate in MMD.

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

0 new messages