[swift-evolution] [Draft] Allow multiple conformances to the same protocol
Jordan Rose
jordan_rose at apple.com
Wed Jun 8 16:32:22 CDT 2016
Associated types aren't generic parameters; the whole point is that they're requirements, just like the other declarations in a protocol.
You might be trying to invent generic protocols instead, which (IIRC) aren't inherently a bad thing. But I think this needs a lot more fleshing out before it can really be discussed—it's hard to know how you can and can't use these things, and how they might be implemented.
Best,
Jordan
> On Jun 8, 2016, at 12:07, Антон Жилин via swift-evolution <swift-evolution at swift.org> wrote:
>
> ==Motivation==
>
> protocol From {
> associatedtype FromType
> init(_ value: FromType)
> }
>
> The problem is, one type cannot implement multiple From "conversions".
>
> ==Proposed solution==
>
> Allow specifying all associated types using generic syntax.
>
> extension Int : From<Float> { }
> extension Int : From<Double> { }
>
> This is only allowed in conformance declarations.
>
> ==Future directions==
>
> We can replace all *Convertible protocols with From and Into, which will be defined similarly to Rust.
>
> - Anton
> _______________________________________________
> 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