<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="">Sorry, something is up with my email address.&nbsp;<div class=""><br class=""><div><blockquote type="cite" class=""></blockquote><font color="#5856d6" class=""><br class=""></font>Oooh and one more, the Infinite Loop:<br class=""><font color="#5856d6" class=""><br class=""></font><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">repeat</span><span class="" style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;"> {</span><br class=""><font color="#5856d6" face="Menlo" class=""><span style="font-size: 11px;" class=""><br class=""></span></font><span style="font-family: Menlo; font-size: 11px;" class="">}</span><br class=""><font color="#5856d6" class=""><br class=""><br class=""></font><blockquote type="cite" 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=""><div class=""><div class=""><div class="">On Dec 9, 2015, at 12:58 PM, Tyler Cloutier via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><blockquote type="cite" class=""></blockquote><font color="#00afcd" class=""><br class=""></font>I’m still of the belief that all types of loops could be condensed down to a single type of loop, the repeat-for loop<br class=""><font color="#00afcd" class=""><br class=""></font>Consider:<br class=""><font color="#00afcd" class=""><br class=""><br class=""></font>The for-in loop:<br class=""><font color="#00afcd" class=""><br class=""></font><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">repeat</span><span class="" style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;"> </span><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">for</span><span class="" style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;"> x </span><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">in</span><span class="" style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;"> </span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(39, 42, 216);">0</span><span class="" style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;">..&lt;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(39, 42, 216);">5</span><span class="" style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;"> {</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp; &nbsp;&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(0, 132, 0);">// code</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class="">}</span><br class=""><font color="#00afcd" class=""><br class=""></font>The C style for loop and the while loop:<br class=""><font color="#00afcd" class=""><br class=""></font><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">repeat</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">for</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">var</span><span style="font-family: Menlo; font-size: 11px;" class=""> i = </span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(39, 42, 216);">0</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">while</span><span style="font-family: Menlo; font-size: 11px;" class=""> someCondition(i) {</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp; &nbsp;&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(0, 132, 0);">// code</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class="">}&nbsp;</span><br class=""><font color="#00afcd" class=""><br class=""><br class=""></font>The repeat while:<br class=""><font color="#00afcd" class=""><br class=""></font><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">repeat</span><span class="" style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;"> </span><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">for</span><span class="" style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;"> </span><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">var</span><span class="" style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;"> i = </span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(39, 42, 216);">0</span><span class="" style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;"> {</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp; &nbsp;&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(0, 132, 0);">// code</span><br class=""><span class="" style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px;">} </span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">while</span><span class="" style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px;"> someConditionEvaluatedAfterFirstLoop() </span><span style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px;" class="">// The i variable would likely have to be considered in scope in the while expression</span><br class=""><font color="#00afcd" class=""><br class=""><br class=""></font>The currently discussed repeat loop<br class=""><font color="#00afcd" class=""><br class=""></font><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">repeat</span><span class="" style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;"> </span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(39, 42, 216);">5</span><span class="" style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;"> {</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp; &nbsp;&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(0, 132, 0);">// code</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class="">}</span><br class=""><font color="#00afcd" class=""><br class=""></font>All follow a very basic pattern: The repeat keyword followed by a for declaration of loop scoped variables, then either a condition in the case of while or an iterator in the case of for-in. Optionally the language could include an “always” keyword that would specify a set of statements that were guaranteed to execute after each run of the loop. For example:<br class=""><font color="#00afcd" class=""><br class=""></font><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">repeat</span><span class="" style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;"> </span><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">for</span><span class="" style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;"> </span><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">var</span><span class="" style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;"> i = </span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(39, 42, 216);">0</span><span class="" style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;"> </span><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">while</span><span class="" style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;"> i &lt; </span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(39, 42, 216);">5</span><span class="" style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;"> {</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp; &nbsp;&nbsp;</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class="">} always i += </span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(39, 42, 216);">1</span><br class=""><font color="#272ad8" face="Menlo" class=""><span style="font-size: 11px;" class=""><br class=""></span></font>If this were the case then all current loop constructs and their features could be subsumed by a single type of loop (including the to-be-removed C style for). This does have the problem of increasing the length of some current loop constructs though, specifically for-in.<br class=""><font color="#00afcd" class=""><br class=""></font>Tyler<br class=""><font color="#00afcd" class=""><br class=""><br class=""><br class=""></font><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=DOmV4Qxg-2B1XOnX4CfTyH3sCllXs7myBcgXMCpdkqNW0viJYpkySO22kXjWCOeeSXdj9apwOibzlX25k2sgnNJHwr3OphN6vJh6UDPNRZG9aZvII51sf-2BqQFNGwdMB5-2Bi6PwecdFPsoFg1uuSPTRS-2BSfqrgDCxgXVZAiLjF-2Fy-2FB40By1hefobcRvd1nFOMgLTXZvV-2F8F63AfCTjMP4Kd-2FrLevjnost841KHVmZJt93qA-3D" alt="" width="1" height="1" border="0" class="" style="height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;"><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""><blockquote type="cite" class=""><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=""><div class=""><div class=""><div class=""><div class="">On Dec 8, 2015, at 10:05 PM, André Videla via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><blockquote type="cite" class=""></blockquote><font color="#12c00e" class=""><br class=""></font>How about having a default implementation in the standard library for it?&nbsp;<br class="">We avoid syntactic sugar and we allow for this very simple yet useful expression.<br class="">And we’ve seen solutions in this thread using autoclosurses and extensions<br class=""><font color="#12c00e" class=""><br class=""></font>5.times {<br class="">&nbsp; &nbsp;…<br class="">}<br class=""><font color="#12c00e" class=""><br class=""></font>or a function<br class=""><font color="#12c00e" class=""><br class=""></font>repeat(4) {<br class="">&nbsp; &nbsp;…<br class="">}<br class=""><font color="#12c00e" class=""><br class=""></font>all sound good to me.<br class=""><font color="#12c00e" class=""><br class=""></font>- André<br class=""><font color="#12c00e" class=""><br class=""><br class=""><br class=""></font><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=DOmV4Qxg-2B1XOnX4CfTyH3sCllXs7myBcgXMCpdkqNW1zhhmu5CjhfG-2BP2cjImP8nbF1kxPNzJeSqU-2FN8MEq05R9af7oiQFjalFbSVz-2FM-2FkEhvIrTmq3QcHxHgbzAgfXOAhB4Bb-2Ffjvwkzz2q5H1w7z-2BPIOeIZ1JH2Yl-2FMTVmvoMcxhVvu8prN9FoT6ay4U8Lqe4NkrkrLCUZMyOakSyBdFAa578gBycVgeAnNXAvwRI-3D" alt="" width="1" height="1" border="0" class="" style="height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;"><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""><blockquote type="cite" class=""><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=""><div class="">On 09 Dec 2015, at 06:58, Chris Lattner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><blockquote type="cite" class=""></blockquote><br class="">On Dec 8, 2015, at 4:43 PM, Daniel Steinberg via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><blockquote type="cite" class=""><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=""><div class=""><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">For me this comes up when teaching children or new programmers. (Perhaps not a valid use case)</div></div></div></div></div></blockquote><br class="">This is a very valid use case.<br class=""><br class="">FWIW, “repeat N {}” was originally designed and scoped into the Swift 2 implementation of the feature, but was cut due to schedule limitations. &nbsp;There is precedent for this sort of feature in many teaching oriented languages (e.g. Logo).<br class=""><br class="">I’d say that the pro’s and con’s of this are:<br class=""><br class="">+ Makes a simple case very simple, particularly important in teaching.<br class="">+ Even if you aren’t familiar with it, you can tell at first glance what the behavior is.<br class="">- It is “just syntactic sugar”, which makes the language more complex.<br class="">- It is a very narrow feature that is useful in few practical situations.<br class=""><br class="">-Chris<br class=""><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=41N46VivWCZSszJfIBo5GmyHxjrOakJAcXHty8ZW-2FGhs8teaOUlcVyh8QnI9g7h0iDnLCWCVHmPKUk54l97lzseMpm3DSkV0swNaGZto3zxhnMCqLQO4eo92JbTfmmNB8XrsSs3G-2BE6Bhpo-2FZpKiHAXDZYkMyynnOU2qAQADCwtl8wEB8zy3IqigpG6fQdiX7kYktIL4GEZUVkI-2BmLE0cA-3D-3D" alt="" width="1" height="1" border="0" class="" style="height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;"><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><div class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></div>
</div></div></blockquote></div></div></div></div>
</div></div></blockquote></div></div></div></div></blockquote></div><br class=""></div></body></html>