<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>As am I. I like that the while clause can be optional, but I don't see the point of banning "while true".<br><br>- Dave Sweeris</div><div><br>On May 10, 2016, at 14:10, Xiaodi Wu via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div><div style="white-space:pre-wrap">Nicholas wrote that he would like `while true` to be a compile-time error. I'm curious as to why.<br></div><br><div class="gmail_quote"><div dir="ltr">On Tue, May 10, 2016 at 13:47 Tyler Cloutier <<a href="mailto:cloutiertyler@aol.com">cloutiertyler@aol.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><blockquote type="cite"><div>On May 10, 2016, at 12:39 AM, Xiaodi Wu via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div><div class="gmail_extra"><div class="gmail_quote">On Tue, May 10, 2016 at 2:27 AM, Nicholas Maccharoli via swift-evolution<span> </span><span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span><span> </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)"> <span> </span>while true {</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> <span> </span>if ... { break }</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> <span> </span>//...</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> <span> </span>}</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)"> <span> </span>repeat {</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> <span> </span>if ... { break }</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> <span> </span>//...</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> <span> </span>} 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)"> <span> </span>repeat {</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> <span> </span>if ... { break }</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> <span> </span>//...</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> <span> </span>}</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)"> <span> </span>repeat { </div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> <span> </span>foo += bar</div><div style="font-family:'comic sans ms',sans-serif;color:rgb(39,78,19)"> <span> </span>} 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></div></div></div></blockquote><div><br></div></div></div><div style="word-wrap:break-word"><div><div>I don’t think the proposal is forbidding it, but rather making it optional. So that </div><div><br></div><div>repeat {</div><div><br></div><div>} </div><div><br></div><div>is equivalent to </div><div><br></div><div>repeat {</div><div><br></div><div>} while true</div></div></div><div style="word-wrap:break-word"><div><br><blockquote type="cite"><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div><div class="gmail_extra"><div class="gmail_quote"><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" target="_blank">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><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">_______________________________________________</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">swift-evolution mailing list</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="mailto:swift-evolution@swift.org" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">swift-evolution@swift.org</a><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div></div></blockquote></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>