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

Nicholas Maccharoli nmaccharoli at gmail.com
Wed May 11 13:25:16 CDT 2016


Yeah after going though this thread again modifying the repeat keyword
seems like overkill.

while true { } isn't broken but I really like Ruby's loop { ... } keyword.

but adding a new loop type to swift just for replacing a special case of
the while loop also seems like a little too much.

If there isn't a strong argument for adding a loop keyword then I guess
this thread is at it's end for now.

Thanks for the feedback!

- Nick


2016年5月12日木曜日、Chris Lattner via swift-evolution<swift-evolution at swift.org
>さんは書きました:

>
> > On May 10, 2016, at 6:11 PM, Tyler Cloutier <cloutiertyler at aol.com
> <javascript:;>> wrote:
> >
> >
> >> On May 10, 2016, at 5:56 PM, Chris Lattner <clattner at apple.com
> <javascript:;>> wrote:
> >>
> >>
> >>> On May 10, 2016, at 4:13 PM, Cole Campbell via swift-evolution <
> swift-evolution at swift.org <javascript:;>> wrote:
> >>>
> >>> I agree that repeat { } is ambiguous because you have to look to the
> end for a while clause to determine if it's infinite or not.
> >>
> >> Right, this is the downside that I see with “repeat {}”.
> >
> >
> > Not to beat a dead horse, but isn’t this also true of
> >
> > repeat { ...
>
> > while true { …
>
> No, because today you always know that repeat has a condition, and that
> while does not.  That’s the point.
>
>
> >> Another option is to make it a statement modifier, which wouldn’t
> require taking it as a keyword (but also doesn’t read as well):
> >>
> >> forever repeat { }
> >>
> >>
> >> Personally, I don’t see this as a big enough improvement over “while
> true” to be worth introducing complexity for.
> >>
> >
> > If you are referring to “forever", I also don’t think that adding a new
> keyword is an improvement over “while true”.
>
> I agree.  Even if it didn’t take a keyword, Idon’t think that “repeat
> forever” is worth adding over “while true”.
>
> -Chris
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org <javascript:;>
> https://lists.swift.org/mailman/listinfo/swift-evolution
>


-- 

All the best,

Nicholas

Linked in:
http://lnkd.in/328U22
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160512/01edbaef/attachment.html>


More information about the swift-evolution mailing list