Well, from my basic understanding of perlop - Assignment Operators those two should be equivalent. Maybe I'm wrong though.
Fortunately, it's a contrived example anyway.
| [reply] |
| [reply] |
Tye, don't be silly. I get where you're coming from since you're trying to explain WHY they are different. However, implementations details including optimizations don't matter. Either the language works as documented in perlop or it doesn't and is a bug:
Assignment operators work as in C. That is,
$a += 2;
is equivalent to
$a = $a + 2;
although without duplicating any side effects that dereferencing the lvalue might trigger, such as from tie(). Other assignment operators work similarly. The following are recognized:
**= += *= &= <<= &&=
-= /= |= >>= ||=
.= %= ^= //=
x=
One of these two things is wrong. Either the documentation or the implementation. My vote is for the implementation.
Although as I said, it's such a contrived example that I can understand why it wouldn't be a big deal, and that the optimization benefits would be worth the sacrifice.
| [reply] [d/l] [select] |