<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 26 Feb 2016, at 02:11, ted van gaalen via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><div class=""><br class="">for var n from 10 to 1 by -1 { } // looping backwards<br class=""></div></blockquote><div><br class=""></div><div>This is currently possible with:</div><div><br class=""></div><div><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>for var n in (1 … 10).reverse()</font></div><div><br class=""></div><div>Which I find pretty simple personally, though being able to do 10 … 1 would be nice.</div><div><br class=""></div><blockquote type="cite" class=""><div class="">for var n from -10 to 12 // here, the compiler assumes and increment value of 1, no "by" is needed.<br class=""></div></blockquote><div><br class=""></div><div>The following already does this one as-is:</div><div><br class=""></div><div><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>for var n in -10 … 12</font></div><div><br class=""></div><blockquote type="cite" class=""><div class="">for var x: Float from -60.0 to 120 by 0.01 { } // this one has many iterations!<br class="">for var d from 0.0 to abyss by -rate {} </div></blockquote><br class=""></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 class=""></div><div>Personally I think that what we need is a more flexible type for the … and ..< 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 class=""></div><div>Plus ideally the new type would be capable of representing a full range of values; I really don’t like that Range<UInt8> is currently limited to 0-254 inclusive, since the endIndex is always exclusive, but that’s another topic really.</div></body></html>