[swift-evolution] [Draft] Allow multiple conformances to the same protocol

Austin Zheng austinzheng at gmail.com
Wed Jun 8 16:41:51 CDT 2016


FWIW they're marked as 'unlikely' here:
https://github.com/apple/swift/blob/master/docs/GenericsManifesto.md#generic-protocols

It would probably be useful to have counterarguments against the points
raised in that document if you want to prepare a proposal.

Austin

On Wed, Jun 8, 2016 at 2:32 PM, Jordan Rose via swift-evolution <
swift-evolution at swift.org> wrote:

> 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
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160608/110a6ce0/attachment.html>


More information about the swift-evolution mailing list