[swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

Jeremy Pereira jeremy.j.pereira at googlemail.com
Wed May 11 08:25:13 CDT 2016

> On 10 May 2016, at 22:27, Tyler Cloutier via swift-evolution <swift-evolution at swift.org> wrote:
> And isn’t this the point really. Yes there are many different ways of doing something, but there should be one obvious way. IMHO, there is nothing more obvious than just 
> repeat {
> }

Yes there is:

    while true {


is more obvious than repeat { … }

In the first case, the fact that it is a “loop forever” is obvious right there at the beginning of the loop. In the second case, you have to seek out the end of the loop to find out that the loop will repeat forever. And it might not be easy to find the correct bare closing brace in a sea of closing braces in a complexly structured program.

> It’s very clear. It’s not about adding complex control flow, it’s about simplifying current syntax. I don’t think anyone is arguing that it’s more powerful than what while loops currently offer.

I don’t think it simplifies the syntax, it adds an extra distinct version of the repeat loop. That’s not simplifying.


More information about the swift-evolution mailing list