[swift-evolution] repeat loop enhancement

Vinicius Vendramini vinivendra at gmail.com
Wed Dec 16 16:25:15 CST 2015


+1 on ‘for 1…5 {‘. It seems intuitive when you already know for-ins, one look at it and you know what it does.Also, in a education setting, it seems easy to grasp and easy to then extend into more complicated for’s.

-1 for adding a new keyword like ‘repeat’. It seems way easier to keep fewer keywords, both for students and for programmers. I already don’t like the fact that we use both ‘for’ and ‘while’ to express loops (this was particularly vexing when I was learning CS) :/

> On Dec 16, 2015, at 5:06 PM, Thorsten Seitz via swift-evolution <swift-evolution at swift.org> wrote:
> 
> So, maybe it would be better to make "break" and "continue" behave like "break" and "next" in Ruby and enable non local return?
> Then we would not need new syntax for new control structures but could create them as needed within the language.
> 
> -Thorsten
> 
> Am 14.12.2015 um 12:26 schrieb Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org>:
> 
>>> Why not define a times() or timesRepeat() method on Int taking a closure to execute multiple times, like Erica recently posted and which is common in other languages like Ruby, Smalltalk or (I think) Scala:
>> 
>> In the teaching context, the answer is because it doesn’t actually teach you anything that can be extended to other parts of the language. `times` is a great fit for Ruby because many other Ruby looping constructs are also methods on an object (particularly the `each` loop), and because it works with all the usual loop flow control like `break`. None of these things are true about Swift, so you’re effectively teaching your students a dead end.
>> 
>> -- 
>> Brent Royal-Gordon
>> Architechies
>> 
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list