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

Re: Optional binding

Thread Previous | Thread Next
From:
Larry Wall
Date:
March 6, 2005 23:59
Subject:
Re: Optional binding
Message ID:
20050307075843.GA32657@wall.org
On Sun, Mar 06, 2005 at 02:13:09AM -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);

I think it should say something like:

    Use of undefined value at foo line 2
    x = ; y = 1 2 3; z = 

Optional parameters are greedy, and @a means \@a in a scalar context.

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