Compound Assignments
Pete Holsberg
pjh at mccc.edu
Fri Apr 12 04:39:42 AEST 1991
In article <15776 at smoke.brl.mil> gwyn at smoke.brl.mil (Doug Gwyn) writes:
=In article <1991Apr8.174951.22448 at mccc.edu> pjh at mccc.edu (Pete Holsberg) writes:
=>= 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.
=>The reference to E1 is ambiguous, as is the entire statement, IMHO.
=>*Which* E1 is evaluated "only once", the E1 op= E2 one or the other?
=>Does it follow that the remaining one is evaluated twice? not at all?
=
=You have GOT to be kidding -- there is nothing at all ambiguous about
=the quoted specification. It is an elegant way of expressing precisely
=the semantics for op=. I suggest you study it until enlightenment
=suddenly dawns upon you.
Nope! Not at all. If the lvalue E1 in "E1 op= E2" is "....evaluated
only once...", how many times is the lvalue E1 in "E1 = E1 op E2"
evaluated? If the answer is "once", why do they say "... ONLY [emphasis
added] once..."
Suppose the lvalue E1 is, say, "x" in both cases. How does it get
evaluated AS AN LVALUE in the second situation?
Thank you for your patience, oh master. Your humble student awaits
enlightenment from your keyboard. ;-)
Pete
--
Prof. Peter J. Holsberg Mercer County Community College
Voice: 609-586-4800 Engineering Technology, Computers and Math
UUCP:...!princeton!mccc!pjh 1200 Old Trenton Road, Trenton, NJ 08690
Internet: pjh at mccc.edu Trenton Computer Festival -- 4/20-21/91
More information about the Comp.lang.c
mailing list