Talk:Inverted syntax: Difference between revisions

(reply to questions asked)
(→‎perl vs. perl6: new section)
Line 23:
 
Mark.
 
== perl vs. perl6 ==
 
Currently, the perl entry says:
 
:In perl, inverted syntax can also be used with the ternary operator:
 
:<lang perl>$a = $ok ? $b : $c; # Traditional syntax
($ok ? $b : $c) = $a; # Inverted syntax
</lang>
 
But:
 
<lang>$ perl -le '$ok= 1; $b= 2; $c= 3; ($a ? $b : $c) = $a; print $a'
 
$ perl -le '$ok= 1; $b= 2; $c= 3; $a = $ok ? $b : $c; print $a'
2
 
$ perl -le '(1 ? 2 : 3) = $a; print $a'
Can't modify constant item in list assignment at -e line 1, near "$a;"
Execution of -e aborted due to compilation errors.
 
$ perl --version
 
This is perl, v5.10.1 ...</lang>
 
So, in some versions of perl the two statements are both legal, but not equivalent.
 
I imagine that the inverted syntax shown here could work in some version of perl6. But I do not yet have any working implementation of perl6 yet, so I do not know if there are additional issues -- Raduko? Pugs? Not yet implemented?. Anyways, I think this one could use some clarity. --[[User:Rdm|Rdm]] 14:21, 6 June 2011 (UTC)
6,962

edits