Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
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 drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2019-12-15 20:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?