<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 21 mars 2016 à 12:29, Taras Zakharko via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> 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=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 21 Mar 2016, at 17:05, ted van gaalen <<a href="mailto:tedvgiosdev@gmail.com" class="">tedvgiosdev@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class="">Hello Taras</div><div class="">Please take a look here:<br class=""><a href="https://en.m.wikipedia.org/wiki/For_loop" class="">https://en.m.wikipedia.org/wiki/For_loop</a></div><div class=""><br class=""></div><div class="">More than 30 ! programming languages since 1957 until now, have their implementation of the for-loop. If it was or is an inferior construct, it would have disappeared long ago. That alone proves that it is not inferior, but indeed very useful.</div></div></div></blockquote><div class=""><br class=""></div><div class="">And how many of them have the C style for(;;) loop? I don’t even know why the article refers to it as the ‘traditional’ for. Its not traditional, its just popular (because it was introduced with C). The traditional for is the one found in Fotran/Pascal etc. as it actually has that explicit ‘loop variable’ semantics. The C for(;;) loop does not have it. </div><div class=""><br class=""></div><div class="">And by the way, I was never suggesting that Swift should drop for loops altogether. I am just saying that the iterator-based for loop is more then adequate for any conceivable purpose (see below). The reason why early languages do not use iterator-based loops is because the computers were less advances back then, as was our understanding of compilers and computer science. Iterator-based loops incur a high abstraction cost, which can be completely removed by an optimising compiler nowadays. There is of course the issue with the debug-build performance, but I am sure that this too can be remedied eventually. </div><br class=""><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><div class=""><br class=""></div><div class="">There is imho no longer any need to compare the for... variants any longer (but of course feel free to do so), because they both serve different purposes very well. Neither one or the other is inferior! I would protest with equal energy also when the for...in... was removed, because this would make iterating with collections cumbersome, e.g. I am now very happy that I can now iterate through an array, without specifying start, length and where we are.. </div></div></div></blockquote><div class=""><br class=""></div><div class="">I do not think it is appropriate to think about these constructions in terms of inferior/superior. The fact is that the traditional for loop (iterating trough some numbers) is a strict subset of iterator-based loops. Iterator-based loops can do all things that traditional for loops do and then some more. Which make the traditional loop unnecessary. Again, I dislike the C-style for(;;) loop because it has its own, extended semantics which makes it a hybrid between a for-loop and a while loop. </div><div class=""><br class=""></div><div class="">To reiterate, I don’t see the point in having multiple distinct syntaxes for loops when the same thing can be accomplished (and often more compactly so) using the iterator loop. This is just shuffling the syntax around, for no win or reason I can reasonably see. For instance, what you suggest below can be easily done with iterators (and its how Python, R and many other languages do it):</div><div class=""><br class=""></div><div class="">for i in seq(f, t, by:b, while: w) { }</div><div class="">for i in c.filter(condition) { }</div></div></div></div></blockquote><div><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) or are each value dynamically created? Having an explicit legacy loop format gives a feel of control. So something like</div><div><br class=""></div><div>for i from 2 to 1_000_000 by 1 where i % 2 != 0 while foundCount < 5 { print(i); foundCount +=1 }</div><div><br class=""></div><div>sounds less magical and seems easier to predict than</div><div><br class=""></div><div><div>for i in 2.stride(to:1_000_000, by:1).filter({ $0 % 2 != 0}).prefix(5) { print(i) }</div><div><br class=""></div><div>and is still quite readable, even if it mixes for loop, while loop and even simple condition.</div><div><br class=""></div><div>Sorry if the example is a bit dumb as is; but I was too lazy to provide some nice code instead of the simple print.</div><div>Can anyone tell if the filter.prefix above is lazy and that each number is create one by one?</div><div>The fact that using 1_000_000 above caused my playground to crash, seems to indicate that the list of number is pre-generated.</div><div><br class=""></div><div>Dany</div><div class=""><br class=""></div></div><div><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class="">Furthermore, with iterator based loops you are free to extend your for loop as your demands change, to produce shorter, more efficient and safer code (see my example with matrix index iteration in the previous mail). </div><div class=""><br class=""></div><div class="">— Taras</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><div class=""><br class=""></div><div class="">Concerning my intended proposal for a good alternative for the classicsl for-loop, I am currently in favor of very much something like this version, as it is implemented in Maple:</div><div class=""> -----------start copy from wkpd page-----------------------------------</div><div class=""><div style="margin: 0.5em 0px 1em; padding: 0px; border: 0px; line-height: inherit; vertical-align: baseline; background-image: none;" class=""><br class="webkit-block-placeholder"></div><blockquote type="cite" class=""><p style="margin: 0.5em 0px 1em; padding: 0px; border: 0px; line-height: inherit; vertical-align: baseline; background-image: none;" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">Maple has two forms of for-loop, one for iterating of a range of values, and the other for iterating over the contents of a container. The value range form is as follows:</span></p><pre style="margin-top: 0px; margin-bottom: 0px; padding: 1em; border: 1px solid rgb(204, 204, 204); line-height: inherit; vertical-align: baseline; background-image: none;" class=""><font face="UICTFontTextStyleTallBody" class=""><span style="white-space: normal; background-color: rgba(255, 255, 255, 0);" class=""><b style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">for</b> <i style="margin: 0px; padding: 0px; border: 0px; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">i</i> <b style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">from</b> <i style="margin: 0px; padding: 0px; border: 0px; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">f</i> <b style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">by</b> <i style="margin: 0px; padding: 0px; border: 0px; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">b</i> <b style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">to</b> <i style="margin: 0px; padding: 0px; border: 0px; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">t</i> <b style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">while</b> <i style="margin: 0px; padding: 0px; border: 0px; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">w</i> <b style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">do</b>
<i style="margin: 0px; padding: 0px; border: 0px; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class=""># loop body</i>
<b style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">od</b>;
</span></font></pre><p style="margin: 0.5em 0px 1em; padding: 0px; border: 0px; line-height: inherit; vertical-align: baseline; background-image: none;" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">All parts except <code style="margin: 0px; padding: 0.2em 0.5em; border: 1px solid rgb(204, 204, 204); font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class=""><b style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">do</b></code> and <code style="margin: 0px; padding: 0.2em 0.5em; border: 1px solid rgb(204, 204, 204); font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class=""><b style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">od</b></code> are optional. The <code style="margin: 0px; padding: 0.2em 0.5em; border: 1px solid rgb(204, 204, 204); font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class=""><b style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">for</b> <i style="margin: 0px; padding: 0px; border: 0px; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">i</i></code> part, if present, must come first. The remaining parts (<code style="margin: 0px; padding: 0.2em 0.5em; border: 1px solid rgb(204, 204, 204); font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class=""><b style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">from</b> <i style="margin: 0px; padding: 0px; border: 0px; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">f</i></code>, <code style="margin: 0px; padding: 0.2em 0.5em; border: 1px solid rgb(204, 204, 204); font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class=""><b style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">by</b> <i style="margin: 0px; padding: 0px; border: 0px; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">b</i></code>, <code style="margin: 0px; padding: 0.2em 0.5em; border: 1px solid rgb(204, 204, 204); font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class=""><b style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">to</b> <i style="margin: 0px; padding: 0px; border: 0px; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">t</i></code>, <code style="margin: 0px; padding: 0.2em 0.5em; border: 1px solid rgb(204, 204, 204); font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class=""><b style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">while</b> <i style="margin: 0px; padding: 0px; border: 0px; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">w</i></code>) can appear in any order.</span></p><p style="margin: 0.5em 0px 1em; padding: 0px; border: 0px; line-height: inherit; vertical-align: baseline; background-image: none;" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">Iterating over a container is done using this form of loop:</span></p><pre style="margin-top: 0px; margin-bottom: 0px; padding: 1em; border: 1px solid rgb(204, 204, 204); line-height: inherit; vertical-align: baseline; background-image: none;" class=""><font face="UICTFontTextStyleTallBody" class=""><span style="white-space: normal; background-color: rgba(255, 255, 255, 0);" class=""><b style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">for</b> <i style="margin: 0px; padding: 0px; border: 0px; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">e</i> <b style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">in</b> <i style="margin: 0px; padding: 0px; border: 0px; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">c</i> <b style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">while</b> <i style="margin: 0px; padding: 0px; border: 0px; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">w</i> <b style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">do</b>
<i style="margin: 0px; padding: 0px; border: 0px; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class=""># loop body</i>
<b style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">od</b>;
</span></font></pre><p style="margin: 0.5em 0px 1em; padding: 0px; border: 0px; line-height: inherit; vertical-align: baseline; background-image: none;" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">The <code style="margin: 0px; padding: 0.2em 0.5em; border: 1px solid rgb(204, 204, 204); font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class=""><b style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">in</b> <i style="margin: 0px; padding: 0px; border: 0px; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">c</i></code> clause specifies the container, which may be a list, set, sum, product, unevaluated function, array, or an object implementing an iterator.</span></p><p style="margin: 0.5em 0px 1em; padding: 0px; border: 0px; line-height: inherit; vertical-align: baseline; background-image: none;" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">A for-loop may be terminated by <code style="margin: 0px; padding: 0.2em 0.5em; border: 1px solid rgb(204, 204, 204); font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class=""><b style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">od</b></code>, <code style="margin: 0px; padding: 0.2em 0.5em; border: 1px solid rgb(204, 204, 204); font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class=""><b style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">end</b></code>, or <code style="margin: 0px; padding: 0.2em 0.5em; border: 1px solid rgb(204, 204, 204); font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class=""><b style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; background-image: none;" class="">end do</b></code>.</span></p></blockquote><p style="margin: 0.5em 0px 1em; padding: 0px; border: 0px; line-height: inherit; vertical-align: baseline; background-image: none;" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">------------------------------end copy-------------------------------------------</span></p>( in the above example replace "do" and "od" by { } )</div><div class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">Maple has two forms of for-loop, one for iterating of a range of values, </span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">and the other for iterating over the contents of a container.</span></div><div class="">In Maple, which by the way is a very advanced programming language for mathematicians ( i am not), both variants are available and co-exist independently, which is exactly my point! So again, it is not replacing or even changing the for-in as it is now available in Swift, both versions should be available. (This would still be the case if the for ;; had not been removed in the first place)</div><div class="">To get back to the Maple for-loop implementation, in Swift I'd drop the "while" extension.</div><div class="">To summarize:</div><div class=""><br class=""></div><div class="">I would like to see in Swift:</div><div class=""><br class=""></div><div class=""> for v from v1 to v2 by v3 {...}</div><div class=""><br class=""></div><div class="">for numerical values Int, Double, Float...</div><div class="">The "by" clause would be optional: when omitted, it should</div><div class="">default to 1 for integers and 1.0 for floating point values.</div><div class=""> </div><div class="">The loop variable ("v" here) cannot be altered in the loop.</div><div class="">The loop can exited with the "break" statement.</div><div class="">Use "continue" to directly go to the next iteration( if any)</div><div class="">("break" and "continue" functional as it is now)</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Examples:</div><div class=""> for v from 0.5 to 30.0 by 0.3 </div><div class=""> for v from 0 to 100 by 5</div><div class=""> for v from 12.0 to -10.0 by -2</div><div class=""><br class=""></div><div class="">Imho, this is super clean and very readable, Why would anyone have objections against it? Also the compiler can optimize this construct very easely. </div><div class="">Yes, the classical for ;; had more options, but are they still needed? </div><div class=""><br class=""></div><div class="">Note that we also have discussed the floating point number tolerance problem previously. </div><div class="">the for ... from ... to ... by ... could therefore for floating point numbers perhaps be enhanced like so:</div><div class=""><br class=""></div><div class=""> for v from 0.0 to 10.0 by 0.1 tolerance 0.01 // tolerance optional clause</div><div class=""><br class=""></div><div class="">so that it reaches the end value 10.0 in this case</div><div class=""><br class=""></div><div class="">(I am not in favor to automatically set tolerance based upon magnitude)</div><div class=""><br class=""></div><div class="">To summarize:</div><div class=""><br class=""></div><div class="">1. the existing for ... in ... which is nearly perfect for collections can remain as is. No conflicts here. There is no need to drop one for the other, they are completely independent. </div><div class=""><br class=""></div><div class="">2. The new for ... from ... to ... by ... is simple,straightforward and easy to implement.</div><div class=""><br class=""></div><div class="">You've mentioned this:</div><div class=""><blockquote type="cite" class=""><div class=""><font class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">for (i,j,k) in matrix.indices {...</span></font><span style="background-color: rgba(255, 255, 255, 0);" class="">}</span></div></blockquote></div><div class="">but here we are working with collection (descendants), are we?</div><div class=""><br class=""></div><div class="">I'd kindly recommend us all to travel much to other programming worlds, because there are so many (often forgotten) very interesting aspects and ideas that can be very useful to implement in new languages.</div><div class=""><br class=""></div><div class="">Kind Regards</div><div class="">TedvG</div><div class=""><div class=""><div class=""><div class=""><div apple-content-edited="true" class=""><div class=""><div class=""><font class=""><span style="background-color: rgba(255, 255, 255, 0);" class=""></span></font></div></div></div></div></div></div></div><div class=""><br class="">On 21 Mar 2016, at 14:30, Taras Zakharko <<a href="mailto:taras.zakharko@uzh.ch" class="">taras.zakharko@uzh.ch</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class="">To be honest, I have difficulty understanding the premise of this discussion. I have always found the C-style for(;;) loop an awkward construct, because it is essentially just an alternative form of writing a general-purpose while loop. It is perfectly reasonable to restrict the for construct to, well, ‘for’ contexts: iterating through a sequence of items. If you need something more complex, either write your own iterator or use a general-purpose while loop. <div class=""><br class=""></div><div class="">As discussed previously, an optimising compiler generates the same machine code whether you are using an iterator abstraction or low-level coding. Besides, the for .. in .. construct potentially offers more potential for optimisation, because it makes the counter variable as well as the semantics of the entire loop more explicit (a for(;;) can contain arbitrary stuff). Talking about numerical algorithms: this is something I can’t understand at all. I have been working with numerical algorithms in Python and R for years, and I have never ever missed the C-style for loop. These languages offer convenient functions for generating iterable sequences, which are more readable and also represent the loop semantics much better then the for(;;;). Not to mention that the iterator pattern allows you to write simpler and more maintainable code. Imagine iterating through a sparse matrix or something. With a proper iterator pattern you just do:</div><div class=""><br class=""></div><div class="">for (i,j,k) in matrix.indices {</div><div class=""><br class=""></div><div class="">}</div><div class=""><br class=""></div><div class="">With a for(;;) loop you’l probably end up writing a nested construct of quite some complexity. </div><div class=""> </div><div class="">Swift could certainly use some improvements to its iterators (for example something like Python generator expressions might be useful), but that is a different topic. </div><div class=""><br class=""></div><div class="">To sum it up:</div><div class="">- for(;;) is an awkward construct which is closer to a while loop than an actual sequence iterator pattern (that it should be)</div><div class="">- a proper iterator pattern is more convenient, more readable and offers the same performance</div><div class="">- numerical code does not need a for(;;) construct, in fact, using the proper iterator pattern makes writing numeric code easier, not more difficult, because you can abstract away some common processing/aggregating steps easily, and without any drawback</div><div class="">- we should think about how to improve the iterators offered by Swift standard library, not go back to an inferior construction</div><div class=""><br class=""></div><div class="">— Taras</div><div class=""><div class=""><div class=""><br class=""></div><div class=""><div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 21 Mar 2016, at 12:37, Greg Parker via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" 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="Apple-interchange-newline">On Mar 19, 2016, at 12:46 AM, Dmitri Gribenko via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class="">Hi Ted,<br class=""><br class="">Thank you for starting this thread. I agree that removing the C-style<br class="">for loop has degraded the readability and clarity of some of numerics<br class="">code.<br class=""><br class="">In the feedback to SE-0007 many people have said that they can convert<br class="">their code to for-in loops, but I think this actually means that in<br class="">code that is typically written in Swift today, loops primarily operate<br class="">on sequences and collections. It means that numerics is a domain that<br class="">not many people work in. But it is a very important domain<br class="">nevertheless, and clarity for numerics code matters at least as much<br class="">as it does everywhere else.<br class=""><br class="">I think one way to approach this discussion would be to present<br class="">multiple concrete code samples that contain C-style for loops and are<br class="">awkward to write without them. We can then try looking for patterns,<br class="">generalize and simplify, and discuss possible solutions.<br class=""></blockquote><br 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=""><span 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; float: none; display: inline !important;" class="">Let me emphasize this more strongly. *Concrete*, *real-world* examples are quite likely the only way that you are going to get `for(;;)` back or get any sort of semantically-similar syntactically-different replacement.</span><br 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 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=""><span 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; float: none; display: inline !important;" class="">There have been lots of suggestions. None of them are perfect. If we assume that there is in fact no perfect solution then the only way to proceed is to provide sufficient justification for some imperfect solution.</span><br 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 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=""><span 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; float: none; display: inline !important;" class="">I'm still waiting for something like this: "We ported our code to Swift 3. Here are 5 reasonable-looking for(;;) loop shapes from 150 call sites, and here are their ugly-looking rewrites."</span><br 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 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=""><span 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; float: none; display: inline !important;" class="">(Personally I think removing for(;;) without direct replacement was too aggressive. That view lost. Now its advocates will need to do more work to upend the status quo.)</span><br 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 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 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=""><span 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; float: none; display: inline !important;" class="">--<span class="Apple-converted-space"> </span></span><br 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=""><span 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; float: none; display: inline !important;" class="">Greg Parker </span><a href="mailto:gparker@apple.com" 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="">gparker@apple.com</a><span 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; float: none; display: inline !important;" class=""><span class="Apple-converted-space"> </span> Runtime Wrangler</span><br 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 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 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=""><span 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; float: none; display: inline !important;" class="">_______________________________________________</span><br 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=""><span 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; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br 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=""><a href="mailto:swift-evolution@swift.org" 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="">swift-evolution@swift.org</a><br 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=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" 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="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></div></div></div></div></div></blockquote></div></div></blockquote></div><br class=""></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>