Skip to main content

Timeline for Correct For Loop Design

Current License: CC BY-SA 3.0

6 events
when toggle format what by license comment
Feb 26, 2012 at 6:37 comment added Keith Thompson @MadKeithV: How so? In this particular context, i++ and ++i are identical; they both increment i, and the result is discarded. (There are reasons to prefer preincrement in C++ for non-elementary types, neither of which applies here.)
Jan 26, 2012 at 13:30 comment added Paul @MadKeithV Sorry, I learned C before we knew about correctness and Standards :)
Dec 12, 2011 at 23:57 comment added Yttrill @Paul: You understand the problem is that the expansion of the syntax isn't type dependent. And yes, Felix has a "for element in array" function: iter, as well as folds etc. They're implemented with the for loop, see: felix-lang.org/$/usr/local/lib/felix/felix-latest/lib/std/…
Dec 12, 2011 at 21:26 comment added Izkata @MadKeithV Yet if you'll notice, all the answers are using postincrement, because that's the idiom inside a for loop in C. Besides which, the compiler should be able to optimize it into a preincrement since the value is just being thrown away.
Dec 12, 2011 at 14:10 comment added Joris Timmermans Pet peave: do NOT use postincrement in this situation, it's semantically the wrong choice.
Dec 12, 2011 at 14:09 history answered Paul CC BY-SA 3.0