[swift-evolution] [Review] SE-0065 A New Model for Collections and Indices

plx plxswift at icloud.com
Mon Apr 18 18:04:57 CDT 2016

> On Apr 18, 2016, at 4:52 PM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:

> Again you're encoding “I'm at the end” in the index, which as we've
> agreed does not work.

If nothing else, it works—and seems natural—for linked lists. 

Sorry; if I’d remembered this elementary example sooner I would’ve lead with it.

I’ll point it out then be completely done.

> So one special index value “moves automatically as the collection changes” and
> all others do not.  Doesn't seem like an advantage to me.  It's easy to
> imagine having subtle bugs due to this difference. 

Again, if you implement a textbook linked-list under collections-move-indices, the natural representation for the indices is arguably `ListNode<T>?` (or whatever), wherein you use `nil` for the end index. 

As a consequence, at least in this scenario you wind up with the semantics/behavior sketched previously for `endIndex`. 

No further reply is needed; thank you for sharing your insight.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160418/277702ab/attachment.html>

More information about the swift-evolution mailing list