PS:
> endIndex is exclusive by definition
If you want a rationale on this...
1) It's how cursors typically work, and people familiar with the concept
already expect this.
2) It's often the most convenient choice. Back in the day, you would write C
code like this:
for (int *cur = array, *end = array + size; cur < end; ++cur) {
process(*cur);
}
Similarly, you can compute the number of elements by just getting the
distance between startIndex and endIndex (or end - cur in the C example above).
Making the upper boundary inclusive would require explicit '- 1' and '+ 1'
in quite a few places, which is ugly and unnecessary.
3) The upper bound is almost always excluded in programming, in many unrelated
APIs (e.g. arc4random_uniform), so it's a good default choice.
A.
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution