Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Pre vs Post Incrementing variables

by JavaFan (Canon)
on Sep 12, 2010 at 16:32 UTC ( #859875=note: print w/replies, xml ) Need Help??


in reply to Re: Pre vs Post Incrementing variables
in thread Pre vs Post Incrementing variables

The main reason it's declared as "undefined" is that the current implementation surprises many people, and can only be justified by exposing the implementation. Out of the two evils "having undefined behaviour" and "exposing the implementation to the language", I think the first one is the lesser.

If you really need to increment $i twice, just write it in more than one statement:

print $i + 1, $i + 1; $i += 2;
Or:
print do {$i += 1}, do {$i += 1};

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2020-10-28 17:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (263 votes). Check out past polls.

    Notices?