4 ms·
The problem is that the i++ goes at the end of the loop body. When the loop body is long, the increment can be many many lines away from the initialization and
by legalcorrection 5y ago
The problem is that the i++ goes at the end of the loop body. When the loop body is long, the increment can be many many lines away from the initialization and loop condition. The increment won't always be as obvious as "i++" and can involve function calls. With a well-written for loop, you can see all of that at a glance.
- zozbot234 5y ago> With a well-written for loop, you can see all of that at a glance. Yes, this is ultimately about the push for structured programming, which involves creating a pattern language of loops with "clean" semantics. Grouping the loop advancing statement with the other parts of a general loop construct helps wrt. recognition of known looping patterns.