Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

To be honest I haven’t seen a single programming language that has decent enums.

With that I mean fundamental and fool proof functions for to/from a string, to/from an int, exhaustive switch cases, pattern matching, enumerating.

Seems like something that wouldn’t be too hard but everybody always fails on something.



> I haven’t seen a single programming language that has decent enums.

There's not much you can do with an enumeration. It's just something that counts one-by-one.

A useful tool when you have a large set of constants that you want to number, without having to manually sit there 0, 1, 2, 3... But that's the extent of what it can offer.

> With that I mean fundamental and fool proof functions for to/from a string, to/from an int, exhaustive switch cases, pattern matching, enumerating.

While a programming language may expose this kind of functionality, none of these are properties of enums. They are completely separate features. Which you recognize, given that you are able to refer to them by name. Calling these enums is like calling if statements functions because if statements may be layered with functions.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: