3 ms·
> Could you not get most of the benefits of ADTs using structs + unions + enums? The modelling aspects can be simulated, yes, but that's barely half of the ben
by naasking 2y ago
> Could you not get most of the benefits of ADTs using structs + unions + enums?
The modelling aspects can be simulated, yes, but that's barely half of the benefits of ADTs. Pattern matching is a big ergonomic benefit.
- cryptonector 2y agoTFA gets pattern matching. The critical thing is that the compiler (or macro system) needs to check that you've checked all the alternatives.
- naasking 2y agoYes TFA is pretty close, but note that it's not just "structs + unions + enums" getting you "most of the benefits", which is what I was responding to. There's a buttload of macros hiding allocation and switch statements.