<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Great point; an infinite loop syntax would make a lot of sense. &nbsp;It seems good for it to have its own syntax, considering you must have a `break` or `return` to escape it. &nbsp;`while true { }` provides the same functionality, though it seems a bit less direct in its purpose than `repeat { &nbsp;}` could.</div><br class=""><div><blockquote type="cite" class=""><div class="">On Jul 18, 2016, at 4:16 PM, Haravikk &lt;<a href="mailto:swift-evolution@haravikk.me" class="">swift-evolution@haravikk.me</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 18 Jul 2016, at 21:32, Sean Heber via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">I’ve wanted this myself, too, so I’m generally +1, although I’ve also wondered if maybe this syntax should be changed somehow. I’ve not put a lot of thought into it, and this perhaps has come up before, but I sort of wonder.. would it make more sense to get rid of the trailing “while” entirely?<br class=""><br class="">Here’s what I’m thinking:<br class=""><br class="">This repeats forever - infinite loop:<br class=""><br class="">repeat {}<br class=""><br class="">And to get out of the infinite loop, you’d just use an if or guard the same way you might in any other loop in some cases:<br class=""><br class="">repeat {<br class=""> &nbsp;let success = doSomething()<br class=""> &nbsp;guard success else { break }<br class="">}<br class=""><br class="">We could potentially even warn if you use a repeat {} without there being a break inside the body somewhere.<br class=""><br class="">This way, we eliminate a special syntactical form (repeat/while has always felt weird in every brace-based language I’ve used) and just piggyback on the existing break/continue/guard/if mechanisms that are already there and common. Then we also don’t need to have a special “weird” rule where the scope of variables change magically for repeat/while.<br class=""><br class="">l8r<br class="">Sean</div></div></blockquote><br class=""></div><div class="">That's a very interesting alternative, especially with a warning when there's no break (or return), and it would be clearer about the scope. Actually now I think about it, the repeat/while is a little odd in Swift since the while condition doesn't require parenthesis, which is great for a regular while or if condition because the braces give it structure, but that's not quite the case with the repeat/while.</div><div class=""><br class=""></div><div class="">I'm fine either way, but this should be explored as well; guard in particular goes well this style of repeat syntax. More interestingly though is that this would actually allow us to write while loops as:</div><div class=""><br class=""></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>repeat {</font></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">                </span>guard someCondition() else { break }</font></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">                </span>doSomething()</font></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</font></div><div class=""><br class=""></div><div class="">while would essentially just become a shorthand.</div></div></div></blockquote></div><br class=""></body></html>