[swift-evolution] Inheritance with a Constrain

Kevin Wooten kdubb at me.com
Wed Dec 9 04:18:12 CST 2015


I have ran into this problem multiple times now.  When creating libraries for Thrift and YAML parsing we were forced to create wrapper objects for Array, Set & Dictionary to make then Hashable for Hashable elements; made me feel dirty as the solution seemed so obvious that I couldn’t believe it wasn’t already available.

That being said. This is specifically mentioned as “in scope” for Swift 3 (under Generics).  Does that mean a proposal is already available from the internal Swift team? Is it already being developed internally?

> On Dec 9, 2015, at 12:09 AM, Thane Gill via swift-evolution <swift-evolution at swift.org> wrote:
> 
> There have been many use cases that I’ve come across where I want to do something like this:
> 
> protocol SomeProtocol { }
> 
> extension Array: SomeProtocol where Element: SomeProtocol { }
> 
> This seems like a something that swift should move toward as it is a “protocol oriented language”. This would enable ease of building new libraries that need to extend collection types and other storage type classes in the standard library.
> 
> - Thane Gill
> 
> _______________________________________________
> 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