<div dir="ltr"><div><div class="gmail_extra"><div class="gmail_quote">On Tue, May 10, 2016 at 2:27 AM, Nicholas Maccharoli via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)">Swift Evolution Community,</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"><br></div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)">Currently writing an infinite loop in swift looks either something like this:</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"><br></div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> while true {</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> if ... { break }</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> //...</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> }</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"><br></div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)">Or this:</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"><br></div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> repeat {</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> if ... { break }</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> //...</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> } while true</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"><br></div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)">But I think it might be best to change the syntax / behaviour of `repeat` to loop </div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)">indefinitely if no trailing while clause is present:</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"><br></div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> repeat {</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> if ... { break }</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> //...</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> }</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"><br></div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)">while still allowing a trailing `while` clause as in:</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"><br></div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> repeat { </div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> foo += bar</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> } while foo.count < limit </div></div></blockquote><div> </div><div>What is your motivation for this change?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"></div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)">I also want to propose that it should be a compile time error to use single `Bool` constants as while loop conditions, so no more `while true { ... }` it would become `repeat { ... }`</div></div></blockquote><div><br></div><div>What problems are solved by forbidding `while true`?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)">I was thinking of drafting a short proposal if there was enough positive feedback. <br></div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"><br></div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)">How does it sound?</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"><br></div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)">- Nick </div></div>
<br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div></div></div>