[swift-evolution] Type information containing multiple additional protocols

Matthew Johnson matthew at anandabits.com
Wed Dec 16 09:24:21 CST 2015


I don’t believe the implementers who would need to face the complexities in the implementation believe those are compelling examples.  It needs to be clear why a structural union is necessary rather than an enum.  To be clear: structural unions are to enums as tuples are to structs.

> On Dec 16, 2015, at 9:16 AM, Marc Knaup <marc at knaup.koeln> wrote:
> 
> Enumerations are a good example. 
> Or JSON nodes.
> 
> https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/002474.html <https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/002474.html>
> On Dec 16, 2015 16:05, "Matthew Johnson" <matthew at anandabits.com <mailto:matthew at anandabits.com>> wrote:
> 
>> // require value to be of type Bool OR Double OR String OR SomeProtocol
>> let value: (Bool | Double | String | SomeProtocol)
>> switch value {
>>    case let _ as Bool: …
>>    case let _ as Double: …
>>    case let _ as String: …
>>    case let _ as SomeProtocol: …
>>    // no default necessary
>> }
> 
> This is a structural union type which has received considerable discussion with commentary from core team members already in the with a subject something like "STL and Either".  You may be interested in reading that discussion.  The summary is that we are unlikely to see it without extremely compelling use cases.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151216/176a70aa/attachment.html>


More information about the swift-evolution mailing list