[swift-evolution] Review for: Remove C-style for-loops with conditions and incrementers

Rainer Brockerhoff rainer at brockerhoff.net
Sat Dec 12 17:30:47 CST 2015


On 12/12/15 17:48, Michel Fortin wrote:
> It'd certainly be useful if the C-style for loop disappear to have a
> decent way to express it using a while loop, but I'm not sure this is
> the way to go. As things stand, we have the following ideas about
> augmenting a while loop (with various keywords I won't enumerate):
> 
> while condition() next increment() { body() }
> 
> while condition() { body() } repeat { increment() }
> 
> Perhaps we could consider adding something like `defer` but that
> would not execute on `break` or `throw`:
> 
> while condition() { reloop { increment() } body() }
> 
> Or maybe just make the whole C-style for loop a special kind of while
> loop by replacing semicolons with keywords:
> 
> for var i = 0 while condition() next increment() { body() }
> 
> There's so many ideas floating around, but it doesn't seem like any
> of them is getting much traction right now.

Thanks for the round-up. You're right.

I'll think this over and re-read the grammar before commenting further.

-- 
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