[swift-evolution] Add ability to validate collection indices

Dave Abrahams dabrahams at apple.com
Sun Dec 18 21:10:13 CST 2016

on Fri Dec 16 2016, Daniel Vollmer <swift-evolution at swift.org> wrote:

> Hi,
>> On 16 Dec 2016, at 14:56, Alexey Komnin via swift-evolution <swift-evolution at swift.org> wrote:
> [snip]
>> What do you think? I feel, like we should discuss it before I
>> formalize it as a proposal.
> I think this is a fruitless attempt, as even if the indices are still valid,
> they may not refer to the same elements they referenced before the mutation.
> Of course, mutating methods should state whether the invalidate existing
> indices, but I think that’s about the best that can be reasonably
> done.

We can do a bit more.  For example, RangeReplaceableCollection's
replaceRange should return the range in the new collection state
corresponding to the elements that were replaced.  


More information about the swift-evolution mailing list