5 ms·
Golang's iota enums seem to me to be at least equivalent to C-tier enums. The iota syntax helper is even an improvement. https://golang.org/ref/spec#Iota https
by ovi256 8y ago
Golang's iota enums seem to me to be at least equivalent to C-tier enums. The iota syntax helper is even an improvement.
https://golang.org/ref/spec#Iota https://golang.org/ref/spec#Iota
- monocasa 8y agoThey're not. Better C compilers understand for warning purposes stuff like "you've used all but one of this enum in a switch case block, are you sure you don't want to use all of them"?
- roganartu 8y agoThat's not a language feature though, that's a compiler feature. The Go compiler should be technically capable of doing that without breaking iota or introducing a new feature. Have you considered raising a request for it if one doesn't already exist?
- elithrar 8y agoIt might even be best as a vet or metachecking feature. Go’s compiler toolchain does not “warn” users by design: only hard errors.
- roganartu 8y agoYeah you're right, I should've been more specific than "compiler" here. In fact, the varcheck checker in gometalinter probably even covers this use case: https://github.com/alecthomas/gometalinter/blob/master/README.md#supported-linters https://github.com/alecthomas/gometalinter/blob/master/READM...
- monocasa 8y agoPeople tend to put all kinds of random stuff in const blocks, because it looks like import blocks, and a file level thing rather than a soecific set of constants thing.