Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!pacbell.com!att!cbnewsh!rkl From: rkl@cbnewsh.att.com (kevin.laux) Newsgroups: comp.lang.c Subject: Re: Compound Assignments Message-ID: <1991Apr16.125259.9072@cbnewsh.att.com> Date: 16 Apr 91 12:52:59 GMT References: <1991Apr8.174951.22448@mccc.edu> <15776@smoke.brl.mil> <15823@smoke.brl.mil> Distribution: na Organization: AT&T Bell Laboratories Lines: 32 In article <15823@smoke.brl.mil>, gwyn@smoke.brl.mil (Doug Gwyn) writes: > 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. [stuff about ambiguity and understanding deleted] I think the problem of 'ambiguity' arises from what expressions are chosen as examples. For instance, (E1 = x) x += y and x = x + y produce the same result but might cause one to say E1 evaluated only once? Whereas (E1 = x [i++]) x [i++] += y and x [i++] = x [i++] + y do not produce the same result but more clearly illustrates the point that in compound assignments E1 is evaluated only once. -- ________________________________________________________________________________ R. Kevin Laux Email: rkl1@hound.att.com AT&T Bell Labs Voice: (908) 949-1160 Holmdel, NJ 07733 Fax: (908) 949-0959