5 ms·
While I agree with you, I can understand going with enum so that they don't scare away the C and C++ crowd with being too fartsy with theoretic stuff.
by hurril 3y ago
While I agree with you, I can understand going with enum so that they don't scare away the C and C++ crowd with being too fartsy with theoretic stuff.
- MuffinFlavored 3y agothey scared me away when I tried to do from/to u32 and comparing them, etc.
- flohofwoe 3y agoIt is especially confusing for C and C++ coders, because Rust enums are a completely different thing than C enums, which makes the naming choice worse than just inventing a new name. Better names would be "tagged union" (which is spot-on descriptive - because it *is* a union with a tag slapped on - but "tagged_union" of course is a bit unwieldy as keyword) or "variant" (which is the name for that thing in C++ and elsewhere since forever - it's not like Rust invented those tagged-union-thingies, it just added some convenient syntax sugar to the language to deal with them).
- jowea 3y agoMaybe it's because you can use a Rust enum like in C by doing a field-less or unit-only enum?
- hurril 3y agoI agree with you! I dislike the name enum and really like how F# does it. In F#, everything is type and what kind of type you create comes down to the type construction literal you use. ` (* enum ) type 'a Option = Some of 'a | None ` ( struct - well: record. *) type Company = { Name : string Age : int } Fudge. No idea how to format that in HN.
- randomdata 3y agoIn practice, now C developers get to hear from the Rust crowd that C doesn't have enums because what C has is unlike Rust "enums".