|In reply to Comment 216 (Gregg):|
The thing is, no competent C programmer will *think* of it as "assign the sum of x and y to x". What happens here is that the value of x is *incremented* by y.And it's not just that the use of "+=" would immediately signal "increment". The fact that C has predefined operators for increment, decrement, scale and so on means that a competent C programmer will expect any line with a simple "=" assigment operator to do something that can *not* be expressed as an incremet, decrement, scale...Cmoing at it from another way --- "Increment x by y" involves two variables, x and y, and an operation, increment. "x+=y" expresses that. "x=x+y" or worse "x=y+x" involves three variables (two of which happen to be the same, but the reader needs to match those herself), and an operation which is decidedly not "increment".Looking at it yet another way, given two same-integer variables x and y (and where needed a third one z), one *could* write "x^=y; y^=x; x^=y;". Or one could write "z=x; x=y; y=z;". Or one could use "swap(&x,&y);" and have a swap function implemented somewhere else (In C++, using references, one could even have it be "swap(x,y);", and in Perl "($x,$y)=($y,$x);"). All of these do exactly the same thing, and the first version is arguably the fastest and most efficient --- but you would never use it in real code, because the whole connotation of "^=" is "bit operator!", i.e. something that works on individual bits. Yes, it does the right thing in the end, but semantically, it misleads.