[swift-evolution] [Pre-Proposal-Discussion] Union Type - Swift 4

Xiaodi Wu xiaodi.wu at gmail.com
Fri Aug 19 11:25:19 CDT 2016


On Fri, Aug 19, 2016 at 11:07 AM, Tino Heth via swift-evolution <
swift-evolution at swift.org> wrote:

> Hi Cao,
>
> Considering "&" for types is already decided, symmetry would be enough
> motivation for me to add "|" as well.
>

Tino, this line of reasoning was explicitly addressed by the core team when
they approved "&". In fact, it was their "princip[al] concern" about "&":

"The principle concern with this is that having an “&" operator for generic
constraints leads the question of whether the language should introduce an
"|" operator to represent disjunctions in type constraints (something that
the type system cannot and should not support). This is a topic that the
C++ committee grappled with in its discussions of C++ concepts. That said,
the core team feels that “&” directly expresses the relationship that we
want, that “|” can be addressed in the “commonly rejected proposals" list,
and that other proposals for an infix operator (like +) skirt this issue
but are strictly worse at communicating intent in code."


> Maybe I would even support replacing enums with associated values in favor
> of union types (my impression is that enums aren't as useful as I thought
> when I started using them).
>
> But right now, this doesn't seem to be a time for discussing huge changes,
> but for actually implementing smaller ones ;-)
> I'm a little bit concerned that Swift might already be preferring
> compatibility over elegance, but the defensive attitude that you perceived
> might as well be explained with release-stress…
>
> Of course, rejection is still frustrating — but please consider that most
> proposals aren't accompanied by an implementation, so every wish that's
> accepted adds something to the pile of work to be done by the core team.
> Imho it would be nice if Swift evolution would be more "decentralized",
> moving away from proposals like "I want to have feature X" towards "I want
> to develop feature X, is there a chance this could be integrated?", but
> coordination is already hard enough, so this might be unfeasible.
>
> - Tino
> _______________________________________________
> 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/20160819/9230085c/attachment.html>


More information about the swift-evolution mailing list