Hi Internals,

I struggle to understand the benefit of "basic" enumerations and their diminished API. In particular, I often find myself wanting to use |from()/||tryFrom()| to convert a string to an enumeration. To do this, I must convert it to a "backed" enum and copy & paste each name to its value. In all other regards, I still want it to behave like a "basic" enumeration, so I won't abuse the value of the names to act like a mapping; the values will always mirror the names, and if I need to do any mappings, I'll add match() functions.

My question, then, is why can't basic enumerations have these semantics by default? Or, to state it more concretely, what would be the downside to having all "basic" enumerations actually being "backed" enumerations whose values implicitly mirror their names for the purposes of converting to/from strings? Would this not make basic enumeration more useful without any particular downsides?

Kind regards,
Bilge

Reply via email to