diff options
author | Abigail <abigail@abigail.be> | 2004-06-30 14:00:21 +0200 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2004-06-30 12:12:24 +0000 |
commit | 1b721fa2fa5c2aced6815dd64c00f93df966853b (patch) | |
tree | 8f3c8703399154a832ed848549c239be617e4c96 /pod/perlop.pod | |
parent | d59fda8ab38296488317dd54cd5ba5bcbdf13a1a (diff) | |
download | perl-1b721fa2fa5c2aced6815dd64c00f93df966853b.tar.gz |
Documenting undefined behaviour of $i = $i ++.
Message-ID: <20040630100021.GA23752@abigail.nl>
p4raw-id: //depot/perl@23014
Diffstat (limited to 'pod/perlop.pod')
-rw-r--r-- | pod/perlop.pod | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/pod/perlop.pod b/pod/perlop.pod index 6f8e2dd0b7..64206ceea8 100644 --- a/pod/perlop.pod +++ b/pod/perlop.pod @@ -144,6 +144,17 @@ value. print $i++; # prints 0 print ++$j; # prints 1 +Note that just as in C, Perl doesn't define B<when> the variable is +incremented or decremented. You just know it will be done sometime +before or after the value is returned. This also means that modifying +a variable twice in the same statement will lead to undefined behaviour. +Avoid statements like: + + $i = $i ++; + print ++ $i + $i ++; + +Perl will not guarantee what the result of the above statements is. + The auto-increment operator has a little extra builtin magic to it. If you increment a variable that is numeric, or that has ever been used in a numeric context, you get a normal increment. If, however, the |