Who said anything about operand evaluation order? (How could there be an operand evaluation order for a unary operator.)

You did, or rather the passage you quoted. The expressions whose order of evaluation is not defined are those that are operands. The order of those that aren't operands — those that are statements — is well defined.

No, the list operator is not a unary operator.

So, not an lvalue.

It appears that Perl doesn't realise that ++$i returns an lvalue (thus the syntax error), but it does.

$ perl -E'sub { $_[0]="fred"; }->($i++); say $i' 1 $ perl -E'sub { $_[0]="fred"; }->(++$i); say $i' fred

Ah! That well know Perl keyword 'alias'....

You understood what that code did, right? Troll. It's actually an imported function, fyi.

"It" has everything to do with the fact that the evaluation order of sub-expressions is unspecified.

No, even if "it" was specified — it's currently left to right for all the operators involved — the results would be the same.

The fact that f( ++$n, ++$n ) passes an alias to $n, rather than the value resulting from the preincrement, is just another broken behaviour.

That's entirely possible.

It is equivalent to C allowing:

Perl passes args by reference and C can't, so I don't see your point. It is equivalent to C++ allowing:

#include <stdio.h> void f( int &a, int &b ) { printf( "a: %d, b: %d \n", a, b ); a = 3; b = 4; } int main( int argc, char ** argv ) { int x = 0; f( ++x, ++x ); printf( "x: %d \n", x ); return 0; }

Which it does:

$ g++ -o a a.cpp && a a: 2, b: 2 x: 4

In reply to Re^4: Pre vs Post Incrementing variables by ikegami
in thread Pre vs Post Incrementing variables by SavannahLion

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.