[swift-evolution] C-style For Loops

Roland King rols at rols.org
Sat Dec 5 11:28:13 CST 2015

> On 5 Dec 2015, at 19:35, Thorsten Seitz <thorsten.seitz at web.de> wrote:
> I’m not a big fan of the C-style for loop, mostly because i find the parts of it badly separated by those tiny semicolons which are easily overlooked.
> Therefore for me it would be ok if the C-style for loop would be dropped but transforming its syntax into more Swift like syntax like suggested by Tyler might be even better as Roland and Tyler made some good points about advantages of the for loop (especially the guaranteed execution of the increment part). Being able to have the loop variable scoped locally to the loop is another advantage over the while loop.

I’d be perfectly happy if a semantic equivalent, but syntactically more easily comprehensible, alternative to the c-style for loop was introduced. An extension to while sounds reasonable if there’s a version which is generally agreed to be clearer. I’d like not to throw away what the fullness of what a c-style for loop can express, I don’t mind at all if we throw away the semicolons currently used to express it and replace them with an alternative and more readable syntax. I thought Thorsten’s suggestion for one was fine, I’m sure there are others. 

More information about the swift-evolution mailing list