[swift-evolution] subprotocol as type when super protocol has an associated type

Benjamin Spratling bspratling at mac.com
Sat Jun 24 17:30:33 CDT 2017

> On Jun 24, 2017, at 6:24 PM, Anders <hello at andersio.co> wrote:

> The feature you called for is generalized existentials. It is on the Generic Manifesto and had a few long discussion threads on the list before. Apparently, it is out of scope for Swift 4, and whether it is in scope of Swift 5 remains to be seen.

Thanks, I wasn’t sure of the right name for the kind of feature.  I’ll be sure to watch for any related proposals and vote yes early and often. ;-)
I must have missed the discussions.  I had switched to digests for a while, which made following any actual discussion nearly intractable.

> By the way, for your code snippet, apparently you may simply add "doSomething" overloads for `P: B` and `P: C`. The compiler will pick the most specific variant for you at compile time. Deferring to runtime with existentials is not necessarily the only option.

Yes, that’s what I’m doing now, and it felt unnecessary.  There were pieces of my logic which had to be duplicated.


More information about the swift-evolution mailing list