Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: Using ternary operator as lvalue in push

by TimToady (Parson)
on Aug 01, 2007 at 17:17 UTC ( #630123=note: print w/replies, xml ) Need Help??


in reply to Re: Using ternary operator as lvalue in push
in thread Using ternary operator as lvalue in push

It's a hard-wired limitation of Perl 5, but you're not going to have to live with it forever because it's fixed in Perl 6. The way we fixed it was by not committing to scalar/list distinctions until the argument list is actually bound to a function. When we do this, most of the problems of Perl 5's prototypes simply evaporate. In fact, this works fine in pugs:
my @x = my @y = (); push (False,True).pick ?? @x !! @y, <a b c>; say "x: @x[]"; say "y: @y[]";
and randomly pushes the list onto one array or the other.

Replies are listed 'Best First'.
Re^3: Using ternary operator as lvalue in push
by dada (Chaplain) on Aug 02, 2007 at 14:51 UTC
    well, I also expect something like this to work in Perl 6:
    ($cond ?? @x :: @y).push(<a b c>);
    which is a lot more understandable syntax in my opinion.

    cheers,
    Aldo

    King of Laziness, Wizard of Impatience, Lord of Hubris
      As a matter of fact it does:
      pugs$ cat prova.pl && ./pugs prova.pl my @x = my @y = (); ((False,True).pick ?? @x !! @y).push(<a b c>); say "x: @x[]"; say "y: @y[]"; x: a b c y:
      At least now!

      Flavio
      perl -ple'$_=reverse' <<<ti.xittelop@oivalf

      Don't fool yourself.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://630123]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2022-05-27 07:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (94 votes). Check out past polls.

    Notices?