on Wed Mar 23 2016, Howard Lovatt <[email protected]> wrote:
> +1 I think it is a good idea to make a collection run from firstIndex to > lastIndex inclusively (note name change to match firstElement and > lastElement). For an empty collection both firstIndex and lastIndex would > be invalid values that would cause both c[c.firstIndex] and c.[c,lastIndex] > to fail. That direction is pretty much a nonstarter with me. There are *many* algorithms that are correct for empty collections without any special-case testing, as long as you use half-open ranges. There's no reason to make every algorithm that uses indices test for emptiness before proceeding. See also https://www.quora.com/Why-are-Python-ranges-half-open-exclusive-instead-of-closed-inclusive for philosophical background on why most ranges should be half-open. -- Dave _______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
