3 ms·
D enums are not the good kind of enums (i.e. sum types, like in Rust), though. Instead they have some silly implementation of sum types using classes in std.var
by tree_of_item 10y ago
D enums are not the good kind of enums (i.e. sum types, like in Rust), though. Instead they have some silly implementation of sum types using classes in std.variant.
- Profan 10y agoIt's not a class, it's a struct (as a value type), it's fine if you disagree with the idea of OOP, but don't come in with an incorrect assumption of how the language is actually used in the wild. But sure, I would agree that having a natively implemented variant type would be better, even if this one can serve many of the same purposes. Class = reference type, supports polymorphism, inheritance Struct = value type, does not support polymorphism, inheritance The variant type based on a struct is implemented through the language's metaprogramming facilities.
- zem 10y agothis is my primary "complaint" about D; i strongly prefer languages with algebraic datatypes and pattern matching built in. other than that it does indeed look like a beautiful language. ironically, i haven't really used D for the same reason i haven't really used rust - i've yet to have a project for which ocaml wasn't a better choice. (i know both D and rust address things ocaml doesn't, but they aren't the things i tend to need for my personal projects.)