[swift-evolution] Proposal: An Either Type in the STL
Thorsten Seitz
tseitz42 at icloud.com
Sun Dec 13 02:57:34 CST 2015
I don't expect interference to lead to bugs because everything is strongly typed and you would wonder when the compile or IDE tells you that your variable or function should have type Int | String.
But requiring the result type of a conditional to be explicitly typed I could live with if I just get union types :-)
-Thorsten
> Am 12.12.2015 um 20:11 schrieb Matthew Johnson <matthew at anandabits.com>:
>
> I don’t have any experience working in a language with structural sum types but I think inference of structural sums in different branches of a conditional would lead to a lot of bugs and potential confusion. Before considering support of such inference I would want to see pretty compelling evidence that it adds value and doesn’t lead to problems.
>
> In absence of allowing this inference, the structural sum could be specified manually if that is what is intended.
>
>>> On Dec 12, 2015, at 12:48 PM, Thorsten Seitz via swift-evolution <swift-evolution at swift.org> wrote:
>>>
>>>
>>> Am 10.12.2015 um 20:59 schrieb John McCall via swift-evolution <swift-evolution at swift.org>:
>>>
>>> Also, are we allowed to *infer* structural sums? For example, can we decide that the type of (x ? A() : B()) is A+B if that’s the greatest common type?
>>
>> That’s what Ceylon does.
>>
>> -Thorsten
>>
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151213/eeba9ef6/attachment.html>
More information about the swift-evolution
mailing list