[swift-evolution] Enhanced existential types proposal discussion

Austin Zheng austinzheng at gmail.com
Thu May 26 10:34:27 CDT 2016


> On May 26, 2016, at 6:51 AM, Jan E. Schotsman via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
> On May 26, 2016, at 3:44 PM, Austin Zheng wrote:
> 
>> The inimitable Joe Groff provided me with an outline as to how the design
>> could be improved. I've taken the liberty of rewriting parts of the
>> proposal to account for his advice.
> 
> Looks like great progress!
> 
> A few remarks:
> 
> 1.I don't see the need for AllOf. A nested existential also acts as a constraint bundle, so you would have to write
> 
> Any<ProtocolA, AllOf< ProtocolB, ProtocolC>>
> 
> for consistency.
> 
> In a "is subclass of" constraint the superclass also acts as a constraint bundle, in a sense.

It was strawman syntax to allay some concerns were brought up earlier. At this point I think it makes the most sense to wait and see what happens to SE-0095, which will hopefully finalize some sort of existential syntax for Swift 3.x.

> 
> 2.If openas never fails why do we need to use optional binding with it?

No good reason, to be honest. I stole the syntax from the Completing Generics document. The outermost 'openas' shouldn't ever fail, unless somehow additional requirements or tests (like a where clause) could be attached. However, I haven't come up with good syntax for such a case, though - "do x openas T { ... }" is almost as horrific.

> 
> 3. You have a typo in the "where clause" section:  where Collection.Element == Streamable

Oops, good catch. I'll fix that.

> 
> _______________________________________________
> 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