[swift-evolution] [Pitch] Remove destructive consumption from Sequence

Dave Abrahams dabrahams at apple.com
Tue Jul 5 16:04:42 CDT 2016


on Tue Jul 05 2016, David Waite <david-AT-alkaline-solutions.com> wrote:

>> On Jul 1, 2016, at 9:59 AM, Matthew Johnson via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>>> 
>>> On Jun 30, 2016, at 12:26 PM, Dave Abrahams <dabrahams at apple.com> wrote:
>>> 
>>> Q: Why not allow endIndex to have a different type from startIndex?
>>> A: It appears to offer insufficient benefit for the associated
>>>  complexity in typical usage.  A classic use case that argues for a
>>>  different endIndex type is the null-terminated C string.  But you
>>>  can't index one of those safely without actually counting the length,
>>>  and once you've done that you can make the endIndex an Int.
>> 
>> It’s also worth nothing that we can use `Optional` with `nil` as the `endIndex` sentinel if necessary.
>
> I don’t believe this is true? Optional cannot support Equatable w/o
> generics changes. I believe we would need a different wrapper type.

Correct.

-- 
Dave


More information about the swift-evolution mailing list