Compound Assignments (was Re: Another <sigh> error!)
Blair P. Houghton
bhoughto at nevin.intel.com
Tue Apr 9 17:16:48 AEST 1991
In article <1991Apr7.185259.12709 at druid.uucp> darcy at druid.uucp (D'Arcy J.M. Cain) writes:
>In article <1991Apr6.195901.25255 at dvorak.amd.com> Tim Olson writes:
>>in 3.3.16.2 (Compound assignment):
>> A compound assignment of the form E1 op= E2 differs from the
>> simple assignment expression E1 = E1 op (E2) only in that the
>> lvalue E1 is evaluated only once.
>
>Huh? Am I missing something or does that say that the two expressions
>*ARE* evaluated differently? What it says is that the number of times
>x is evaluated is the *only* difference but it is a difference.
You must be missing something, because it clearly says they are
evaluated differently and you shouldn't be confused about that.
But the original expressions didn't involve any side effects
other than the assignment itself, so no difference results.
Obviously, a confluence of side-effects creates mass hysteria
between the two:
*(f(i++)) *= 2; /* cool */
*(f(i++)) = *(f(i++)) * 2; /* cholesterol */
--Blair
"The cow operator tends to
chew things of type cud
more than once..."
More information about the Comp.lang.c
mailing list