[swift-evolution] Synthesizing Equatable, Hashable, and Comparable for tuple types

Chris Lattner clattner at nondot.org
Fri Nov 24 18:06:44 CST 2017


On Nov 24, 2017, at 3:47 PM, Douglas Gregor via swift-evolution <swift-evolution at swift.org> wrote:
> One could imagine adding a “curry” operation to function types:

Right, having non-nominal types participate in the generics system would be undoubtably awesome! :)

> Or perhaps making metatypes Hashable so they can be used as keys into a Dictionary:
> 
>   extension<T> T.Type: Hashable {

Ok, so you just happened to pick a simple one: what is the benefit of plumbing knowledge of metatypes through the entire generics system, rather than define a “Swift.Metatype” type, and defining stuff against it?

-Chris



>     var hashValue: Int {
>       return ObjectIdentifier(self).hashValue
>     }
> 
>    static func ==(lhs: T.Type, rhs: T.Type) -> Bool { /* standard library magic */ }
>   }
> 
> 	- Doug
> 
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list