points by viega 3 hours ago | 0 comments
I always use unsigned values and do:
while (i-- != 0) { ... }
It's more clear than the most idiomatic way, which is to drop the explicit comparison: while (i--) { ... }
All of it is better than the clunky old for-loop syntax.
Usually, this won't happen of course, but because `i` is not declared inside a for-loop, it must have been declared outside, and thus might even look like a regular variable that could be used by some "clever" coding to multipurpose it!
In any case, it's a niche worry i have, so i usually don't do it if i know there's a for loop that would do.