[swift-evolution] Will existentials ever conform to their protocols?

Slava Pestov spestov at apple.com
Wed Jan 18 00:50:56 CST 2017


> On Jan 17, 2017, at 9:33 PM, David Sweeris via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
> On Jan 17, 2017, at 22:30, Braeden Profile via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> 
>> Hello Swift Community!
>> 
>> I know that I’ve seen this mentioned before, but what with Enhanced Existentials being brought up, I think this is worth mentioning now.  What is the plan regarding letting existentials conform to their protocols?  Currently, in Swift 3, it is impossible to write code like this:
>> protocol Updatable
>> 	{ func update() }
>> 
>> struct UpdatePool<T: Updatable>
>> 	{ /* ... */ }
>> 
>> let heterogenousPool = UpdatePool<Updatable>()
>> Error on the last line:  “Using ‘Updatable’ as a concrete type conforming to protocol ‘Updatable’ is not supported.”
>> 
>> 
>> Although my most common use case of this behavior has actually been solved (using ‘AnyObject’ as a concrete type conforming to ‘AnyObject’), I wonder why this can’t be extended to any protocol existential (a field which is about to explode, if we succeed in Enhancing them).
>> 
>> What do you guys think?
> 
> +1, but I think there's a compiler limitation preventing it at the moment.

See my recent post: https://www.mail-archive.com/swift-users@swift.org/msg03427.html

Slava


> 
> - Dave Sweeris 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170117/b8d6984e/attachment.html>


More information about the swift-evolution mailing list