Front page | perl.perl6.language |
Postings from March 2005
Re: Optional binding
Thread Previous
|
Thread Next
From:
David Storrs
Date:
March 7, 2005 08:13
Subject:
Re: Optional binding
Message ID:
20050307161319.GB69114@megazone.bigpanda.com
On Sun, Mar 06, 2005 at 11:58:43PM -0800, Larry Wall wrote:
> 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
Urk. I, for one, will definitely find this surprising. I would have
expected:
x = <whatever>; $y = 1; z = 2 3
But I suppose it's all a question of learning to love the Brave New
World in which arrays are actually objects (sort of).
--Dks
--
dstorrs@dstorrs.com
Thread Previous
|
Thread Next