Make types Hashable

I would love one day to make a huge breaking change and implement Universal Equality and Hashability:

  1. Provide global func ==<T>(lhs: T, rhs: T) handling any type, including meta types, tuples, existential containers and functions. Similar for hashing.
  2. Move equality and hashability witness to VWT.
  3. Replace Equatable/Hashable with CustomEquatable/CustomHashable similar to CustomStringConvertible and CustomReflectable.
  4. Drop === and use == to compare references. Disallow classes to conform to CustomEquatable/CustomHashable.

Reasoning for the last one - if reference equality is not what you need, then your entity should not be modeled as a reference type, but rather a value type that uses heap allocation as its implementation detail.

EDIT:

  1. And it also requires stable weak reference - currently references to zombie side tables are dropped during copying.
3 Likes