Hacker News new | ask | show | jobs
by xigoi 1575 days ago
>As for C-style for loops, they are not obsolete by any stretch and any one who thinks so in think that the compiler can easily optimize a magical complex iterator without any problem.

In Nim, non-closure iterators are guaranteed to be inlined, so `for i in 0..<16` always compiles to what you'd write in C.

>In languages without C-style for loops, you'll see people try to emulate them regardless with variables and a while loop, not just an iterator.

There's no “emulation” going on. A C-style for loop is literally just different syntax for a while loop.