develooper Front page | perl.perl5.porters | Postings from October 2016

Re: (\@a) = \($x,$y) in non-void context

Thread Previous | Thread Next
From:
H.Merijn Brand
Date:
October 17, 2016 09:32
Subject:
Re: (\@a) = \($x,$y) in non-void context
Message ID:
20161017113203.3f56658d@pc09.procura.nl
On Mon, 17 Oct 2016 09:13:29 +0100, Dave Mitchell <davem@iabyn.com>
wrote:

> I've just spotted another issue with list assignment in list context.
> Does anyone think the third case below is a bug? I think it should output
> "1:u" like the second case:

/me agrees. +1

>     sub f { print join(':', map $_ // "u", @_), "\n"; }
> 
>     f(($a,$b)     = () ); # prints "u:u"
>     f(($a,$b)     = (1)); # prints "1:u"
>     f(($a,$b, %h) = (1)); # prints "1"
> 
> on the principle that the return value of a list assignment is its LHS;
> i.e. that @a = ((X) = (Y)) should be equivalent to (X) = (Y); @a = (X),
> where (X) is a list of lvals, like ($a, undef, %h)

-- 
H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
using perl5.00307 .. 5.25   porting perl5 on HP-UX, AIX, and openSUSE
http://mirrors.develooper.com/hpux/        http://www.test-smoke.org/
http://qa.perl.org   http://www.goldmark.org/jeff/stupid-disclaimers/

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