<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="">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>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><br class=""></div><div>Reusing my bad example, without the from/to/by:</div><div><br class=""></div><div><div>for i in 2.stride(to: 1_000_000, by: 1)</div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if i % 2 != 0 { continue }</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>print(i)</div><div><span class="Apple-tab-span" style="white-space: pre;">        </span>foundCount += 1</div><div><span class="Apple-tab-span" style="white-space: pre;">        </span>if foundCount &gt;= 5 { break }</div><div>}</div><div><br class=""></div><div>// Where clause already work in current Swift</div><div><div>for i in 2.stride(to: 1_000_000, by: 1)</div><div>where i % 2 == 0</div><div>{</div><div><span class="Apple-tab-span" style="white-space: pre;">        </span>print(i)</div><div><span class="Apple-tab-span" style="white-space: pre;">        </span>foundCount += 1</div><div><span class="Apple-tab-span" style="white-space: pre;">        </span>if foundCount &gt;= 5 { break }</div><div>}</div><div class=""><br class=""></div><div class="">// While do not exist yet in this context</div><div>for i in 2.stride(to: 1_000_000, by: 1)</div><div>where i % 2 == 0</div><div>while foundCount &lt; 5</div><div>{</div><div><span class="Apple-tab-span" style="white-space: pre;">        </span>print(i)</div><div><span class="Apple-tab-span" style="white-space: pre;">        </span>foundCount += 1</div><div>}</div><div><br class=""></div><div>Dany</div><div class=""><br class=""></div><div class=""><br class=""></div></div></div></body></html>