>> 
>> [1] seems one of Brad's coworkers believes that a for() loop has no place in
>> C
>> and a while loop should always be used.  I obviously disagree (-:
> 
> Well, the compiler converts the for-loop to a while anyway :-)
> 

fair enough.  However.


for (; it != end(); ++it) {
  stuff(it);
}

says "for every element in the range, call stuff()"

while (it != end()) {
  stuff(it++);
}

a) hides the increment and b) implies that end must be recomputed because stuff
it changes the container.  At least that is the standard idiom.

Sure for() may just be syntactic sugar, but choosing the right word to say what
you mean goes a long way to helping people who read your code later.

Reply via email to