Closed aabtop closed 4 years ago
Okay, they both kind of have their own purposes (e.g. you might want to use enums as standard simple enums where every constructor has 0 parameters), plus some map more nicely onto different languages than others.
But for Reify, tagged unions, aka variants, seem much more natural. This is now done in d14ff829a68025404026ec60f2f130c9a8b4eb33 .
Currently, the "enum" based approach, which is native to Haskell and Rust, has a few downsides:
1) It doesn't translate nicely to a variant/union based environment like C++, where an extra datastructure is unnecessarily introduced. In fact, this is also true of enum languages, where you often have "struct Foo; struct Bar;" and "enum MyEnum = MyEnumFoo Foo | MyEnumBar Bar", which is redundant. 2) There is no concept of naming enum constructor parameters, so it encourages nameless fields.