<div dir="ltr">I think people are reading a ..&lt; b as the mathematical notation [a, b) which means {}, null, or empty, not error, if b &lt; a and {a} if b = a. <div><br></div><div>If Range was changed to be an Array like collection indexed from 0 to count and stride was how the indexed counted and was an Int &gt; 0 then the following would make sense in terms of interval mathematics as described above (note how stride refers to how the index counts *not* how the values count): </div><div><br></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">(0 ... -1) == []<br>(0 ..&lt; 0) == []<br><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"></blockquote>(0 ... 0) == [0]<br>(0 ..&lt; 2) == [0, 1]<br></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"></blockquote></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>(0 ... 2) == [0, 1, 2]</div></blockquote><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"></blockquote><div>(0 ..&lt; 4).strided(by: 2) == [0, 1, 2, 3].strided(by: 2) == [0, 2]</div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>(0 ... 4).strided(by: 2) == [0, 1, 2, 3, 4].strided(by: 2) == [0, 2, 4]</div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"></blockquote></div></blockquote></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"></blockquote></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">(0 ..&lt; 2).reversed == [0, 1].reversed == [1, 0]</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">(0 ..&lt; 4).strided(by: 2).reversed == [0, 1, 2, 3].strided(by: 2).reversed == [0, 2].reversed == [2, 0]</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"></blockquote></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">(-2 ..&lt; 2).strided(by: 2).reversed == [-2, -1, 0, 1].strided(by: 2).reversed == [-2, 0].reversed == [0, -2]</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">(-2 ..&lt; 2).reversed.strided(by: 2) == [-2, -1, 0, 1].reversed.strided(by: 2) == [1, 0, -1, -2].strided(by: 2) == [1, -1]</blockquote><br><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"></blockquote><div>Then provide a very general init for Range to cope with difficult cases:</div><div><br></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>init(first: T, isFirstIncluded: Bool = true, last: T, isLastIncluded: Bool = true, stride: Int = 1)</div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>Range(first: 0, last: 0, stride: 0) // ERROR, stride must be &gt; 0</div><div>Range(first: 0, last: 0) == [0]<br></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>Range(first: 0, isFirstIncluded: false, last: 0) == [] // {x | first &lt; x &lt;= last }</div><div>Range(first: 0, last: 0, isLastIncluded: false) == [] // {x | first &lt;= x &lt; last }</div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">Range(first: -2, isFirstIncluded: false, last: 2, isLastIncluded: false) == [-1, 0, 1] <br>Range(first: -2, isFirstIncluded: false, last: 2, isLastIncluded: false, stride: 2) == [-1, 1] <br></blockquote><br></div><div>Note: only ForwardIndexType necessary.</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature">  -- Howard.<br></div></div>
<br><div class="gmail_quote">On 6 April 2016 at 09:22, Dave Abrahams 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"><span class=""><br>
on Tue Apr 05 2016, Erica Sadun &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
<br>
&gt;&gt; On Apr 5, 2016, at 4:17 PM, Dave Abrahams via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; on Tue Apr 05 2016, Erica Sadun &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;<br>
&gt;&gt;&gt;    On Apr 5, 2016, at 1:54 PM, Dave Abrahams<br>
&gt;&gt;&gt;    &lt;<a href="mailto:dabrahams@apple.com">dabrahams@apple.com</a>&gt; wrote:<br>
&gt;&gt;&gt;    IMO this:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;    (-9...0).reverse()<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;    is better than<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;    stride(from: 0, to: -10, by: -1)<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;    What do you think?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; The latter better reflects an author&#39;s actual intent. The former depends on<br>
&gt;&gt;&gt; implementation details, which can be hazy, especially, around the edge cases. It<br>
&gt;&gt;&gt; is quicker to read, understand, and verify that the latter is what is<br>
&gt;&gt;&gt; meant.<br>
&gt;&gt;<br>
&gt;&gt; Except that there seems to be some confusion over what &quot;to:&quot; means, right?<br>
&gt;<br>
&gt; obviously (0..&lt;-10).by(-2) would be best.<br>
<br>
</span>I don&#39;t think that&#39;s obvious at all, because 0 ≮ 10<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Dave<br>
</font></span><div class="HOEnZb"><div class="h5"><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>
</div></div></blockquote></div><br></div>