Carey Brown wrote:car = car++;
Take the car value BEFORE incrementing it and remember it
assign to car the remembered value it had BEFORE incrementing
That will easily make it past the compiler in C and C++ but javac will complain bitterly about it, unless the variables are of type boolean. That has to do with using (or not using) 0 for false and non‑0 or non‑null for true.
Jesse Silverman wrote:. . . while ( var = CONSTANT )
It would have made the difference that matters. Because it looks different from the traditional equals sign, it would have made the mistake obvious.
I don't know how much := would have helped there . . .
Here. Scroll down to §3.2. We don't all believe those suggestions. The only places I would use compounded operators are in something like an array list or an array stack:-See Effective Java by Joshua Bloch, the section about avoiding retaining excess references and causing memory leaks. Compounded ++ and -- operators do cause confusion (see the lion and tiger example from Boyarsky and Selikoff's OCJP revision book), but the idiom values[size++] is common enough that developers need to become familiar with it.
. . . this site has a Style-guide somewhere . . . .
Another different perspective comes from the size of the machine. If you spent thousands of £$ (€ hadn't been invented yet) on memory, and it was still limited in capacity, or your screen struggled to show more than 25 lines at once, every keystroke was expensive, and the old C books showed all sorts of abbreviations. Not only compounded ++ but squeezing the entire logic into the header of a for, so it was respectable to write for(...;...;...);
Tim Holloway wrote:. . . very different perspectives. . . .
It pays to know people in the right places. ;)
Tim Holloway wrote: A friend worked at the local AT&T office...