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

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

Thread Previous | Thread Next
Dave Mitchell
October 17, 2016 08:13
Re: (\@a) = \($x,$y) in non-void context
Message ID:

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:

    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)

The warp engines start playing up a bit, but seem to sort themselves out
after a while without any intervention from boy genius Wesley Crusher.
    -- Things That Never Happen in "Star Trek" #17

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About