develooper Front page | perl.perl6.language | Postings from March 2005

Re: Optional binding

Thread Previous | Thread Next
From:
Aldo Calpini
Date:
March 7, 2005 13:30
Subject:
Re: Optional binding
Message ID:
422CC7D6.3090302@perl.it
Larry Wall wrote:
> Or, assuming you might want to generalize to N dimensions someday, just
> 
>     sub bar (*@coords) {...}
> 
> and deal with it as in Perl 5 as a variadic list.  I suppose one could say
> 
>     sub bar (*@coords is shape(3)) {...}
> 
> and get checking on the argument count.

if I understand correctly, without using multi subs:

     sub bar(@coords is shape(3)) { ... }

     bar(@xyz); # ok
     bar( [$x, $y, $z] ); # ok
     bar($x, $y, $z); # compile-time error

while:

     sub bar(*@coords is shape(3)) { ... }

     bar(@xyz); # ok
     bar( [$x, $y, $z] ); # ok
     bar($x, $y, $z); # ok
     bar <== $x, $y, $z; # still ok

am I right?

cheers,
Aldo


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About