|
|
|
|
|
by bux93
17 days ago
|
|
In the author's mind, it's unexpected/amazing that 'for' can iterate over many types. But it's NOT unexpected/amazing that 'iter' can iterate over many types. I have no idea why. It's not like 'for' is limited to counting in other languages. The grand-daddy in c does something until some condition is false, and that thing can equally be incrementing/decrementing a number or invoking some function. That's what a loop does in any case, it compiles down to a conditional jump (JNE/JE..) Maybe his reason for astonishment is obscured by over-use of an LLM to 'enhance' the text. |
|
C 'for' is a while loop. It's strictly syntactic sugar for an already existing feature. And it's really, really transparent. `for(A; B; C) { do_stuff(); }` isn't just a while loop, it's this while loop:
Other languages have treated for as a separate concept from while. C isn't really informative in that case.