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

Dave Abrahams dabrahams at apple.com
Tue Mar 8 13:48:59 CST 2016

on Tue Mar 08 2016, Joe Groff <swift-evolution at swift.org> wrote:

>> On Mar 7, 2016, at 5:25 PM, Dmitri Gribenko via swift-evolution <swift-evolution at swift.org> wrote:
>> Hi,
>> What does everyone think about requiring indices to conform to
>> Hashable, in addition to the existing requirements for Equatable and
>> Comparable?
>> I don't think this should limit any viable collection designs, and yet
>> might be useful, for example, to store indices in a set.
> Is there a reason for Hashable to be distinct from Equatable at all?
> Every Equatable type can (badly) satisfy the requirements of Hashable
> with `return 0;`, if nothing else.

Implementation burden.  A bad conformance might be worse than no
conformance at all.  Nearly all types in Swift ought to be automatically
equatable and hashable (and maybe comparable), but only if we can do a
decent job for most types.  This is a whole feature space we ought to
discuss separately from this indexing proposal.


More information about the swift-evolution mailing list