<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=""><div class="">Hi Vladimir,</div><div class=""><br class=""></div><div class="">In the past weeks, I wrote extensively on swift-evolution </div><div class="">about an alternative for the classical for-loop. </div><div class="">So extensively that it irritated the ”Collectians” </div><div class="">who (indirectly) classified me and some similar others</div><div class="">as “Forloopians” and also “Traditionalists”… </div><div class="">I consider this as a great honor. :o)</div><div class=""><br class=""></div><div class="">Anyway, among other alternatives, I wrote this on April 5th.2016:</div><div class=""><br class=""></div><div class=""><div class=""></div><blockquote type="cite" class=""><div class="">So, to me the best option is still to bring the for ;; back</div><div class="">or to make a new Swift equivalent for it as described here again.</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">for</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> d </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">from</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">10.0 </span><span class="" style="color: rgb(187, 44, 162);">to </span><span class="" style="color: rgb(39, 42, 216);">5.0 </span><span class="" style="color: rgb(187, 44, 162);">by </span><span class="" style="color: rgb(39, 42, 216);">-0.1</span><span class="" style="color: rgb(187, 44, 162);"> </span><span class="" style="color: rgb(187, 44, 162);">tolerance </span><span class="" style="color: rgb(39, 42, 216);">0.01 //tolerance is optional</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;">{</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"> </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(61, 29, 129);">print</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(d)</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">}</span></div></div></blockquote><div class=""><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"><br class=""></div></div></div><div class=""> for v from v1 to v2 by vstep // it can’t be any simpler than this. </div><div class=""><br class=""></div><div class="">Of course, working with ALL existing numerical types, Int, Float, Double.. </div><div class="">( Btw. me wishing: consolidate all floating point types into just one type, preferably Double!)</div><div class=""><br class=""></div><div class="">Apart from the “tolerance” option, which I intended for float boundaries in for-loops, </div><div class="">this is not my really original idea, because the traditional for-loop exist</div><div class="">more or less like this in most program languages for decades. </div><div class=""><br class=""></div><div class="">What do you think about my suggested for-loop?</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">I don’t like this variant at all:</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><span style="font-size: 14.25px;" class="">for i in (1...10).striding(by: 3) {..}</span><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">for i in (1...10).striding(by: -3) {..}</span><br style="font-size: 14.25px;" class=""></blockquote><br class="">It is downright ugly, cumbersome to write, </div><div class="">hard to read and also functionally very limited: ** </div><div class="">- ranges like (10…-5) are not allowed</div><div class="">- ranges / for..in.. with other numerical types like Float and Double are not possible!</div><div class="">- I am still doubtful about optimization: </div><div class=""> the compiler always has to look what is behind the “in”</div><div class=""><br class=""></div><div class="">Ergo: There is still no good alternative for the classical for ;; that was in Swift.</div><div class=""><br class=""></div><div class="">One has to use “while {...}” loops. </div><div class="">which means specifying an iteration in 3 lines more and a bigger change</div><div class="">for errors. </div><div class=""><br class=""></div><div class=""> <br class=""><blockquote type="cite" class=""><span style="font-size: 14.25px;" class="">But.. compare how the next is more clear and nice looking, has less noise, </span><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">how faster this will be typed.. :</span><br style="font-size: 14.25px;" class=""><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">for i in 1...10 by 3 {...}</span><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">for i in 1...10 by -3 {</span>…<span style="font-size: 14.25px;" class="">}</span><br style="font-size: 14.25px;" class=""></blockquote><div class=""><br class=""></div><div class="">This looks better, indeed,</div><div class="">but still has the same severe limitations **</div><div class=""><br class=""></div><div class=""><br class=""></div><blockquote type="cite" class=""><span style="font-size: 14.25px;" class="">My opinion: this .striding is about Range type. Range type is used in many </span><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">places, not just in for-in loop. It is important to have handy and clear </span><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">methods for Range. But. If we are talking about loop - why(why?) can't we </span><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">have such a great syntax for such a common loop task? </span><br style="font-size: 14.25px;" class=""></blockquote><div class="">That is my honest opinion too.</div><div class=""><br class=""></div><div class=""> The only ambition of the for-loop I presented is for it </div><div class=""> to be a convenience construct for the “while” loop </div><div class="">which it has always been. it is actually the sole</div><div class="">reason why it was invented in the first place.</div><div class=""><br class=""></div><div class="">There is nothing to be ashamed of to bring back </div><div class="">the for ;; . I am very serious here.</div><div class=""><br class=""></div><div class="">It is (was) one of the most powerful control statements in Swift!</div><div class=""><br class=""></div><div class="">IMHO it amazes me that people go through so much </div><div class="">unnecessary effort in an attempt to replace / circumvent</div><div class="">a nearly perfect iteration statement. </div><div class=""><br class=""></div><div class="">But I wrote about all this already too many times.</div><div class=""><br class=""></div><div class="">Please note that I do also see many good things and developments in Swift!</div><div class=""><br class=""></div><div class="">met vriendelijke groeten</div><div class=""><br class=""></div><div class="">TedvG </div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><br class=""></div><div class=""><br class=""></div></body></html>