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

Re: Pre vs Post Incrementing variables

by ikegami (Patriarch)
on Sep 12, 2010 at 16:14 UTC ( [id://859869]=note: print w/replies, xml ) Need Help??


in reply to Pre vs Post Incrementing variables

Given my explanation of the problem, the workaround would be to convert the lvalue returns by the pre-increment operator into rvalues.

>perl -E"say ++$i,++$i;" 22 >perl -E"say 0+(++$i),0+(++$i);" 12

Technically, the operand evaluation order for the comma operator in list context is not defined, but it's not likely to ever change, especially since the operand evaluation order for the comma operator in scalar context is defined.

Replies are listed 'Best First'.
Re^2: Pre vs Post Incrementing variables
by JavaFan (Canon) on Sep 13, 2010 at 21:31 UTC
    Technically, the operand evaluation order for the comma operator in list context is not defined,
    The perlop manual page says in the section about the comma operator:
    In list context, it’s just the list argument separator, and inserts both its arguments into the list. These arguments are also evaluated from left to right.
    This has been in perlop since April 2006.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2025-07-20 15:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.