[swift-evolution] Union instead of Optional

Tino Heth 2th at gmx.de
Sun May 15 06:07:46 CDT 2016


I don't know if there has been any internal discussion about using union-types instead of enums, but afaics, there are no obvious downsides for that approach.

> I'm a little curious as to why union types keep on coming up, when enums can do everything they can and much more (methods, constraints on generic types, conformance to protocols).
Are there any strong reasons why those features would not be possible with union types?

There has been a discussion started because it is a little bit cumbersome to create enum-properties (and methods).
With unions, there would be no need for all those switch-statements, and would be possible to configure cases in a central location.
There has also been a proposal for "anonymous enums", which could be modeled with unions in a very elegant way.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160515/3a284752/attachment.html>


More information about the swift-evolution mailing list