* Sean 'Shaleh' Perry <[EMAIL PROTECTED]> [May 18. 2002 16:47]:
> > 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.
100% agreed, I like for() myself and use it whenever it's appropriate. And
wrt to the while() I would probably do:
while (it != end()) {
stuff(it);
it++;
}
--
Mads Martin J�rgensen, http://mmj.dk
"Why make things difficult, when it is possible to make them cryptic
and totally illogic, with just a little bit more effort?"
-- A. P. J.