|
|
|
|
|
by johnpmayer
4202 days ago
|
|
For the record, I voted for enum, like in rust-lang ;-) This was going to be contentious no matter what. For what it's worth, Wikipedia (top Google result) seems to have a compatible story. Luckily, it's just a conversation change. I think it will be fine, and net more helpful than damaging. The overall goals are intuition and accessibility. |
|
Swift seems to have followed Rust's example with its terminology here, so this issue is hardly settled. It may shake out such that `enum` is used for tagged unions where the variants are declared as part of the type (`enum Foo { Bar, Baz}`) (and hence the variants can't be shared between types, at least not without wrapping in a newly-defined variant), whereas `union` is used for tagged unions where the type is composed from multiple existing types (`type Bar; type Baz; union Foo { Bar | Baz }`).