Earlier quoted context omitted.
How is this any different than Go's existing enumerations, aside from the enumeration also creating an implicit list structure which, while kind of neat, isn't really a property of enumerations. The parent is likely lamenting that Go doesn't enforce compile-time value constraints on enumerated sets like some languages do, but many other languages don't ether. Not even Typescript does. If Typescript doesn't find it im…
> Go's existing enumerations Go doesn't have enumerations. So the first difference would be that my enums would actually exist. > implicit list structure which, while kind of neat, isn't really a property of enumerations It absolutely is, or people wouldn't have been regularly writing enums like typedef enum { KindSimple, KindComplex, KindEmacs, Kind_NUM_VALUES } Kind; which they do about half the time. > likely lame…
That's obviously not true. That's what the iota dance is for.
type Kind int
const (
KindSimple Kind = iota
KindComplex
KindEmacs
Kind_NUM_VALUES
)
Go doesn't have a literal enum keyword, if that's what you mean, but enumerations aren't defined by having a specific keyword or specific syntax. Enumerations are a more general concept, defined as a set of named constants. The above is functionally identical to your example in C, among a host of other languages.> Yes, that's my complaint as well.
Fine, but that's not a property of enumerations. If one wants support for value constraints, surely one should ask for that and not for something the language has had since the beginning?