Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don't know what to tell you, there are just multiple ways to use the same words.

What Rust calls enums are called tagged unions in most other languages. Enum usually refers to a simple collection of named values, what Rust calls fieldless enums or unit-only enums.



> are called tagged unions in most other languages

Not sure about that. Swift also calls them enums, in Java and Kotlin (and maybe Scala? I forget) they're sealed classes/interfaces and in PL theory and many typed FP languages they're called "sum types".


Variant records in Pascal, and related linage language.

Enumerations are a sequence of values.


The "tagged" part is important. They are in fact not called "unions" in most languages, only C-derived languages. And in C, unions are untagged. Only later extensions added tagged union types. So I would contend that unqualified "union type" means an untagged union.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: