4 ms·
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
by hmry 2y ago
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.
- Tainnor 2y ago> 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".
- pjmlp 2y agoVariant records in Pascal, and related linage language. Enumerations are a sequence of values.
- adastra22 2y agoThe "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.