3 ms·
> protocols should be removed from the language. That's a bit harsh. You forget that protocols are useful for generics too. But yes, if they want it to be ext
by Manishearth 11y ago
> protocols should be removed from the language.
That's a bit harsh. You forget that protocols are useful for generics too.
But yes, if they want it to be extensible, protocols would be the way to go.
Looking deeper into the issue, it seems like this isn't really an issue with protocols, just an issue with the design of Hashable or Equatable (either allow Equatable to work with protocol objects, or move the Equatable dependency of Hashable to a different kind of Equatable).
This sounds like a nitpick, but it's the difference between language and API design, and the latter is often easier to evolve. It also means that this can be fixed by a ProtocolHashSet<T> library which does hashing differently without touching the compiler/stdlib at all.