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

Re: Optional binding

Thread Previous
From:
Brent 'Dax' Royal-Gordon
Date:
March 6, 2005 02:17
Subject:
Re: Optional binding
Message ID:
b8b9a51105030602174aae3981@mail.gmail.com
Luke Palmer <luke@luqui.org> wrote:
> What is output:
> 
>     sub foo($x, ?$y, *@z) {
>         say "x = $x; y = $y; z = @z[]";
>     }
> 
>     my @a = (1,2,3);
>     foo($x, @a);

IANALarry, but I'd think

   x = ($x's value); y = 1 2 3; z = 

The $y is implicitly typed Any, and Ref of Array (or maybe just Array)
is consistent with Any; hence $y receives \@a.

-- 
Brent 'Dax' Royal-Gordon <brent@brentdax.com>
Perl and Parrot hacker

"I used to have a life, but I liked mail-reading so much better."

Thread Previous


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