<div dir="ltr">Well... I&#39;m against the removal of C style for loop, but it is gone. (I do not think the `for ... in ...`  is a replacement.) And I&#39;m against the removal of `++` and `--` operator as well. For years to come whenever anyone asks me about it I&#39;m going to say that I was against the removal. ;-)<div><br></div><div>I like the `for ... from ... to .. by ...` syntax. This would be a replacement for the C style loop, not the `for ... in ... ` that, as I see, is a very welcome addition but not a replacement.</div><div><br></div><div>-Van</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 26, 2016 at 1:07 PM, Ted F.A. van Gaalen via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Hello Haravikk,</div><div><br></div><div>Thank you. Yes I know this is possible,</div><div>but my main point is that   for..in..    always expects an instance of some sort of a collection.</div><div><br></div><div>e.g for this for-loop:</div><div><br></div><div>for var x in -60.0.stride(to: 60.0, by:  0.001) </div><div><br></div><div><br></div><div>What I don’t know: (can’t find yet)</div><div>&gt;&gt;  Will in this case a large collection with 120000 elements of Double be created by .stride?</div><div> or</div><div>&gt;&gt;  Does .stride(), which in the end uses a descendant of SequenceType, just calculate a new value each time   for..in..   uses .next() on this collection? </div><div>I hope the latter is true.  </div><div><br></div><div>Can someone clarify this perhaps? </div><div><br></div><div>Still , I’d rather see a for variant with “from”</div><div><br></div><div>e.g.</div><div><br></div><div>    for  x from xmin to xmax by xstep  { }</div><div><br></div><div>    for x from xmax to xmin by -xstep  { } </div><div><br></div><div>    for apple from 1 to applesInTruck  { }</div><div><br></div><div>No need for collections in these cases,</div><div><br></div><div>Shouldn&#39;t be that hard to implement? </div><div><br></div><div>kind regards</div><div>Ted</div><span class="HOEnZb"><font color="#888888"><div><br></div><div><br></div><br><div>
<div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="color:rgb(0,0,0)"><span style="color:rgb(255,0,0);font-family:verdana,sans-serif"><font size="1">ted van gaalen</font></span></div><div style="color:rgb(0,0,0);text-align:start;text-indent:0px;word-wrap:break-word;word-spacing:0px;white-space:normal;text-transform:none;letter-spacing:normal"><font size="1"><br></font></div><div style="text-align:start;text-indent:0px;word-wrap:break-word;word-spacing:0px;white-space:normal;text-transform:none;letter-spacing:normal"><div style="color:rgb(0,0,0)"><div style="color:rgb(0,0,0)"><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
</div></font></span><div><div class="h5">
<br><div><blockquote type="cite"><div>On 26.02.2016, at 12:45, Haravikk &lt;<a href="mailto:swift-evolution@haravikk.me" target="_blank">swift-evolution@haravikk.me</a>&gt; wrote:</div><br><div><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On 26 Feb 2016, at 02:11, ted van gaalen via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><div><br>for var n from 10 to 1 by -1  { }    //  looping backwards<br></div></blockquote><div><br></div><div>This is currently possible with:</div><div><br></div><div><font face="Monaco"><span style="white-space:pre-wrap">        </span>for var n in (1 … 10).reverse()</font></div><div><br></div><div>Which I find pretty simple personally, though being able to do 10 … 1 would be nice.</div><div><br></div><blockquote type="cite"><div>for var n from -10 to 12   // here, the compiler assumes and increment value of 1, no &quot;by&quot; is needed.<br></div></blockquote><div><br></div><div>The following already does this one as-is:</div><div><br></div><div><font face="Monaco"><span style="white-space:pre-wrap">        </span>for var n in -10 … 12</font></div><div><br></div><blockquote type="cite"><div>for var x: Float from -60.0 to 120 by 0.01 { }  // this one has many iterations!<br>for var d from 0.0 to abyss by -rate {} </div></blockquote><br></div><div>These two definitely make more of a case for this. I’m not so sure about introducing new keywords for this though.</div><div><br></div><div>Personally I think that what we need is a more flexible type for the … and ..&lt; operators that is simple two related values in any order, which Range could be instantiated from with more strict conditions (must be low to high) for things like grabbing arrays slices and so-on where the order matters. The basic non-Range would then be optimised for use with loops to give us the greater flexibility without having to do stuff like using .reverse().</div><div><br></div><div>Plus ideally the new type would be capable of representing a full range of values; I really don’t like that Range&lt;UInt8&gt; is currently limited to 0-254 inclusive, since the endIndex is always exclusive, but that’s another topic really.</div></div></div></blockquote></div><br></div></div></div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>