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

Re: Optional binding

Thread Previous | Thread Next
From:
Larry Wall
Date:
March 7, 2005 08:55
Subject:
Re: Optional binding
Message ID:
20050307165514.GC14585@wall.org
On Mon, Mar 07, 2005 at 05:36:08PM +0100, Aldo Calpini wrote:
: but then, you could define:
: 
:     multi sub bar($x, $y, $z) { ... }
:     multi sub bar(@coords is shape(3)) {
:         my($x, $y, $z) = @coords;
:         return bar($x, $y, $z);
:     }
: 
:     bar(@coords); # ok now

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.

Larry

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