[swift-evolution] [Completing Generics] Universal conformances
Joe Groff
jgroff at apple.com
Wed Mar 2 23:15:10 CST 2016
> On Mar 2, 2016, at 5:22 PM, Douglas Gregor via swift-evolution <swift-evolution at swift.org> wrote:
> There are some natural bounds here: one would need to have actual structural types. One would not be able to extend every type:
>
> extension<T> T { // error: neither a structural nor a nominal type
> }
>
> And before you think you’re cleverly making it possible to have a conditional conformance that makes every type T that conforms to protocol P also conform to protocol Q, see the section "Conditional conformances via protocol extensions”, below:
>
> extension<T : P> T : Q { // error: neither a structural nor a nominal type
> }
Though definitely a "power" feature that should be used sparingly, I think there are legitimate use cases for universal conformances. If nothing else, the language imposes de-facto universal members on things, including T.Type and x.dynamicType, and it would be nice if those could be implemented in the standard library and given back as reserved words.
-Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160302/2b4546fe/attachment.html>
More information about the swift-evolution
mailing list