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

Re: Optional binding

Thread Previous | Thread Next
From:
Larry Wall
Date:
March 7, 2005 00:02
Subject:
Re: Optional binding
Message ID:
20050307080229.GB32657@wall.org
On Mon, Mar 07, 2005 at 03:03:08AM +0200, Yuval Kogman wrote:
: On Sun, Mar 06, 2005 at 02:13:09 -0700, Luke Palmer wrote:
: > What is output:
: > 
: >     sub foo($x, ?$y, *@z) {
: >         say "x = $x; y = $y; z = @z[]";
: >     }
: > 
: >     my @a = (1,2,3);
: >     foo($x, @a);
: 
: And is
: 
: 	$a ==> foo $x;
: 
: The same?

Nope, that's part of why we came up with pipes in the first place,
You example (assuming you meant @a there) is equivalent to 

    foo($x, undef, @a);

or
    foo $x <== @a;

or

    foo $x, z => [@a]

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