4 ms·
Haxe also has Enums which are Generalized Algebraic Data Types, and they are called "enums" there as well: https://haxe.org/manual/types-enum-using.html https:/
by gr4vityWall 2y ago
Haxe also has Enums which are Generalized Algebraic Data Types, and they are called "enums" there as well: https://haxe.org/manual/types-enum-using.html https://haxe.org/manual/types-enum-using.html
- samatman 2y agoVery well then: Rust is not the only one to call a variant type / tagged union an enum. It's a nice language feature to have, whatever they decide to call it. It remains a strange choice to refer to this as the true enum, actual enum, real enum, as has started occurring since Rust became prominent. If that's a meaningful concept, it means a set of numeric values which may be referred to by name. This is the original definition and remains the most popular.
- mattgreenrocks 2y agoRust is targeting both users who know the original definition as well as people who don’t. Differentiating between real enums and sum types means the language gets another keyword for a concept that overlaps. From a PL theory perspective, enum denotes an enumerable set of values within a type. It just happens that sums slot in well enough with that.
- bobbylarrybobby 2y agoBut the instances of a sum type aren't enumerable unless all of its generic parameters are enumerable.
- danielscrubs 2y agoChecked the definition. An enum is defined as a set of named constants. Id argue that a set by definition needs to be constrained. If it lacks the constraints/grouping id argue it no longer is a set.
- deleted 2y ago[deleted]