<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 23, 2016, at 6:46 PM, Dany St-Amant 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=""><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="">Le 22 mars 2016 à 21:19, William Dillon &lt;<a href="mailto:william@housedillon.com" class="">william@housedillon.com</a>&gt; a écrit :</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=""><div class=""><blockquote type="cite" class=""><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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 class=""><br class=""></div>These may be compact, but some programmer may fell that they are not in control: do these "stdlib" seq(), c.filter() pre-calculate all the entries (wasting precious cpu cycle if one break out early) &nbsp;or are each value dynamically created? Having an explicit legacy loop format gives a feel of control. So something like</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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 i from 2 to 1_000_000 by 1 where i % 2 != 0 while foundCount &lt; 5 { print(i); foundCount +=1 }</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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="">sounds less magical and seems easier to predict than</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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 class="">for i in 2.stride(to:1_000_000, by:1).filter({ $0 % 2 != 0}).prefix(5) { print(i) }</div><div class=""><br class=""></div><div class="">and is still quite readable, even if it mixes for loop, while loop and even simple condition.</div><div class=""><br class=""></div></div></div></blockquote><br class=""></div><div class="">I disagree. &nbsp;I think the first case is venturing dangerously close to the AppleScript “uncanny valley” of human language-like programming verbs where I never know the exact words and exact order for things. &nbsp;The second example is right out of any functional programming mold, and I fully understand what’s happening, and how to decompose the process to test assumptions. &nbsp;Also, I know how to implement the second case (more or less) from scratch, and that’s pretty huge for me.</div><div class=""><br class=""></div></div></div></blockquote><br class=""></div><div class="">There have been multiple fights over too verbose versus too terse, and on whether or not making it sound like English. I would agree a verbose syntax for a mandatory statement is a pain, but the while and where above are optional. And using them instead of relying on continue or break allow for code intent to be bit clearer.</div><div class=""><br class=""></div><div class="">Reusing my bad example, without the from/to/by:</div><div class=""><br class=""></div><div class=""><div class="">for i in 2.stride(to: 1_000_000, by: 1)</div><div class="">{</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>if i % 2 != 0 { continue }</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>print(i)</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>foundCount += 1</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>if foundCount &gt;= 5 { break }</div><div class="">}</div><div class=""><br class=""></div><div class="">// Where clause already work in current Swift</div><div class=""><div class="">for i in 2.stride(to: 1_000_000, by: 1)</div><div class="">where i % 2 == 0</div><div class="">{</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>print(i)</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>foundCount += 1</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>if foundCount &gt;= 5 { break }</div><div class="">}</div><div class=""><br class=""></div><div class="">// While do not exist yet in this context</div><div class="">for i in 2.stride(to: 1_000_000, by: 1)</div><div class="">where i % 2 == 0</div><div class="">while foundCount &lt; 5</div><div class="">{</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>print(i)</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>foundCount += 1</div><div class="">}</div><div class=""><br class=""></div></div></div></div></div></blockquote><br class=""></div><div>The ‘where’ I can tolerate because there are other examples of such a construct in other parts of the language. &nbsp;The while part is still problematic, because where have you declared it? &nbsp;Do you think declaring a variable for that somewhere outside the context of the loop is cleaner than leaving it entirely within that scope then doing a test and break?</div><div><br class=""></div><div>- Will</div><br class=""></body></html>