Not sure what you are saying?<div><br></div><div> for index in empty.indices {</div><div> // never executed</div><div> }</div><div><br></div><div>Would still work.<br><br>On Friday, 25 March 2016, Dave Abrahams via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
on Wed Mar 23 2016, Howard Lovatt <<a href="javascript:;" onclick="_e(event, 'cvml', 'swift-evolution@swift.org')">swift-evolution@swift.org</a>> wrote:<br>
<br>
> +1 I think it is a good idea to make a collection run from firstIndex to<br>
> lastIndex inclusively (note name change to match firstElement and<br>
> lastElement). For an empty collection both firstIndex and lastIndex would<br>
> be invalid values that would cause both c[c.firstIndex] and c.[c,lastIndex]<br>
> to fail.<br>
<br>
That direction is pretty much a nonstarter with me. There are *many*<br>
algorithms that are correct for empty collections without any<br>
special-case testing, as long as you use half-open ranges. There's no<br>
reason to make every algorithm that uses indices test for emptiness<br>
before proceeding.<br>
<br>
See also<br>
<a href="https://www.quora.com/Why-are-Python-ranges-half-open-exclusive-instead-of-closed-inclusive" target="_blank">https://www.quora.com/Why-are-Python-ranges-half-open-exclusive-instead-of-closed-inclusive</a><br>
for philosophical background on why most ranges should be half-open.<br>
<br>
--<br>
Dave<br>
<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="javascript:;" onclick="_e(event, 'cvml', 'swift-evolution@swift.org')">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div><br><br>-- <br>-- Howard.<br>