Compound Assignments

kevin.laux rkl at cbnewsh.att.com
Tue Apr 16 22:52:59 AEST 1991


In article <15823 at smoke.brl.mil>, gwyn at smoke.brl.mil (Doug Gwyn) writes:
> In article <1991Apr11.183942.2195 at mccc.edu> pjh at mccc.edu (Pete Holsberg) writes:
> >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.

	[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 at hound.att.com
	AT&T Bell Labs				Voice: (908) 949-1160
	Holmdel, NJ 07733			Fax:   (908) 949-0959



More information about the Comp.lang.c mailing list