[swift-evolution] [RFC] New collections model: collections advance indices

Pyry Jahkola pyry.jahkola at iki.fi
Tue Mar 8 05:46:18 CST 2016


> On 08 Mar 2016, at 03:25, Dmitri Gribenko via swift-evolution <swift-evolution at swift.org> wrote:
> 
> What does everyone think about requiring indices to conform to
> Hashable, in addition to the existing requirements for Equatable and
> Comparable?

Why impose such a restriction?

I think it's better to just make any concrete index types (e.g. DictionaryIndex<K,V>) in the standard library Hashable where possible. People are still free to constrain their algorithms to `C : CollectionType where C.Index : Hashable` whenever needed.

Besides, in the proposed design, is it really necessary to make Index also Comparable, or wouldn't Equatable be enough? Is it just a question of convenience and failing to find an example of and index type that's Equatable but not Comparable?

— Pyry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160308/2a92ce46/attachment.html>


More information about the swift-evolution mailing list