[swift-evolution] Proposal: An Either Type in the STL

Joe Groff jgroff at apple.com
Sat Dec 12 13:08:45 CST 2015


> On Dec 12, 2015, at 10:58 AM, Thorsten Seitz <tseitz42 at icloud.com> wrote:
> 
> 
>> Am 12.12.2015 um 19:01 schrieb Joe Groff via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>>:
>> 
>> (T | T | U | V) and (U | T | V) would be distinct types
> 
> That would be unexpected. I’d expect them to be the same type.
> 
> In Ceylon I can do the following without problems:
> String|String|Integer foo = 1;
> Integer|String bar = foo;
> or
> interface Parent {}
> interface ChildA satisfies Parent {}
> interface ChildB satisfies Parent {}
> ChildA a = childA();
> ChildB b = childB();
> Parent p1 = a;
> ChildA|Parent p2 = b;
> Parent p3 = if (x) then a else b;
> Everything fits nicely as expected.

I agree, but making this work massively complicates the type system, as John noted.

-Joe

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


More information about the swift-evolution mailing list