[swift-evolution] Review for: Remove C-style for-loops with conditions and incrementers
Rainer Brockerhoff
rainer at brockerhoff.net
Sat Dec 12 12:42:46 CST 2015
On 12/12/15 16:30, Michel Fortin wrote:
> My guess is that your intent was to have ", " between each item, but
not after the last one. That's not how the increment block works in a
C-style for loop. Try this loop if you want to convince yourself:
>
> for var i = 0; i < 5; i += 1, print(", ", terminator: "") {
> print(i, terminator: "")
> }
Yikes. This is why I dislike the C-stye for loop; I never remember such
details properly, and avoid putting multiple items in there. (Same goes
for function pointer syntax and ObjC block pointer syntax, nested
typedefs, etc.)
Offhand (can't test right now) I suppose that means there's no use in
adding `repeat` (or, `loop`, or whatever) to `for ... in`?
Would you say it'd still be useful for the `while` loop?
--
Rainer Brockerhoff <rainer at brockerhoff.net>
Belo Horizonte, Brazil
"In the affairs of others even fools are wise
In their own business even sages err."
http://brockerhoff.net/blog/
More information about the swift-evolution
mailing list