On Fri, Nov 12, 2021 at 9:20 AM Shreyas Sreenivas <shreyas.sreeniv...@gmail.com> wrote: > > Note, I've already looked at https://golang.org/issue/28987, > https://golang.org/issue/19814, and https://golang.org/issue/28438. All of > them require them to make a change that breaks the compatibility promise. I > want to explore another way of defining enums that is backward compatible. > > Enums as types with constrained values
... > ```go > type Operation string ( > Sum = "+" > Product = "*" > Difference = "-" > Quotient = "%" > ) > ``` The problem I see is that people want different things from enumeration types, and what they want in Go tends to depend on what is provided by other languages with which they are familiar. For example, in C there is no notion of a string associated with an enum. But on the other hand there is a common expectation that it is possible to write a loop over all enumeration values, which is easy in C but is not clearly supported by your suggested syntax. I think it's necessary to first discuss the desired set of features. Until that is done, syntax can be a distraction. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcXZaguwh%3DG_C7BSZ0gYaZA8u3aJtMLWb6WoYac7zYOwfw%40mail.gmail.com.