4 ms·
And enumerations from the start.
by randomdata 3y ago
And enumerations from the start.
- pjmlp 3y agoNo it doesn't, it has a hack using constants and iota.
- randomdata 3y agoWhich is what an enumeration is. Perhaps you're thinking of sum types? They are often confused as enums.
- pjmlp 3y agoNot at all. Go read Algol 60, Pascal, Modula-2, C manuals to understand what enumerations are all about. Not a comic dance between iota and manually written constants.
- randomdata 3y agoIt's always bizarre when someone on a discussion forum defers to the writings of someone else. If that someone else wanted to have a discussion, they could do so themselves. But since I'm in a silly mood, I'll play along with your silliness: From the GNU C manual: "An enumeration type represents a limited set of integer values, each with a name." Which is exactly what Go provides. Which isn't surprising as it is identical to C in that regard.
- pjmlp 3y agoNo my dear, this hack type Operation int const ( Escalated Operation = iota Archived Deleted Completed ) has nothing to do with typedef enum {Escalated, Archived, Deleted, Completed} Operation; Only someone that can't get type systems would ever assert they are the same. Literally "Go enums suck", https://news.ycombinator.com/item?id=39564737 https://news.ycombinator.com/item?id=39564737
- randomdata 3y ago> "Go enums suck" Enums suck, period. That's why many modern languages don't offer enums at all, providing sum types instead, which more accurately model what most people are trying to use enumerations for. It is an antiquated pattern that may have served a useful purpose in the early days of computing, but we've learned a thing or two about programming since then. Well, at least you've come around to recognizing that Go does have enums, even if you needed someone else's words to say it. After all, Go enums can't suck if it doesn't have them. But, of course, Go purposefully tries to be antiquated. That's kind of its whole deal. Naturally it is going to have enums to really drive home the antiquatedness.