Hacker News new | ask | show | jobs
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.

1 comments

  > For the record, I voted for enum, like in rust-lang ;-)
Funny, because there's actually a long, long history of debate around whether Rust should refer to them as unions rather than enums (and change the keyword correspondingly). :) Here's the most recent one that I know of: https://github.com/rust-lang/rfcs/pull/27

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 }`).