3 ms·
C was my first language, and I actually have the opposite opinion - I suspect that calling them 'enums' helps adoption. My reasoning is that phrases like 'tagge
by joshmarlow 3y ago
C was my first language, and I actually have the opposite opinion - I suspect that calling them 'enums' helps adoption. My reasoning is that phrases like 'tagged unions' and 'algebraic datatypes' strike some developers as sounding very academic/ivory tower and so somewhat intimidating. I think this is really unfortunate (and is definitely not universal among developers).
Being able to say 'Rust enums can carry arguments' - for some reason - sounds less intimidating and conveys the core feature.
- flohofwoe 3y agoI agree that something like 'sum type' sounds a bit too esoteric, but IMHO 'tagged union' is very descriptive. It's the same thing as a C union plus a tag indicating the currently active content (and that's also what the memory layout looks like under the hood). (but yeah, 'enum with arguments' also describes it very well)
- LoganDark 3y agoThey do point them out as tagged unions many times in the documentation. But the syntax `tagged_union Whatever {}` doesn't exactly have me jumping out of my seat.
- pavlov 3y agoIt’s not like “enum” and “mut” are complete English words either, so maybe an abbreviation like “tun” could have worked. But honestly I think enum was a better choice.
- LoganDark 3y agoI personally think enum was basically the only reasonable choice, as normal enums really are just a subset of tagged unions. They just happen to support tagged unions on top of them.