in reply to Re: Quantum Weirdness and the Increment Operator
in thread Quantum Weirdness and the Increment Operator

That is not entirely the case here though. See the following code and output.

my $f = 1; print '$f = ', $f, ' and $f + $f++ = ', $f + $f++, "\n"; my $g = 1; print '$g = ', $g; print ' and $g + $g++ = ', $g + $g++, "\n"; __END__ $f = 2 and $f + $f++ = 3 $g = 1 and $g + $g++ = 3

This is not the expected behaviour in C and i'm only auto-increment/decrement a single time.


___________
Eric Hodges

Replies are listed 'Best First'.
Re^3: Quantum Weirdness and the Increment Operator
by gam3 (Curate) on Mar 30, 2005 at 14:42 UTC
    What is undefined is the order of operation. Since ($f + $g++) == ($g++ + $f) this is normally a reasonable assumption, but of course ($f++ + $f) != ($f + $f++).
    -- gam3
    A picture is worth a thousand words, but takes 200K.