Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!rpi!uupsi!cmcl2!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: Compound Assignments Message-ID: <15823@smoke.brl.mil> Date: 15 Apr 91 20:59:55 GMT References: <1991Apr8.174951.22448@mccc.edu> <15776@smoke.brl.mil> <1991Apr11.183942.2195@mccc.edu> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 32 In article <1991Apr11.183942.2195@mccc.edu> pjh@mccc.edu (Pete Holsberg) writes: >In article <15776@smoke.brl.mil> gwyn@smoke.brl.mil (Doug Gwyn) writes: >=In article <1991Apr8.174951.22448@mccc.edu> pjh@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! [drivel deleted] The point I was emphasizing is that you should be able to "grok" the description with practically no effort. If you're having difficulty, you need to alter your thinking about it until you grok it. Probably your problem would be that you're trying to analyze the specification at a more detailed level than necessary for understanding. The description presupposes that you already understand what a simple assignment expression means, and it builds on that knowledge to explain what a compound assignment expression means. It does that by (a) rewriting into terms you should already understand and (b) stating how the actual case differs from the rewrite. I would think that practically any native speaker of English who had already assimilated the semantics of C through simple assignment expressions should understand this specification for compound assignment with no problem at all. Certainly that's the way that I learned about the semantics of compound assignment when I was first learning C, and it was crystal clear to me then.