News for hackers. Stuff that matters.
Re:Enums in Go by dgb23 on Friday July 12, 2024 @05:18AM (#40943963)
Isn’t that the first thing you would do if you add a new variant?
Re:Enums in Go by K0nserv on Friday July 12, 2024 @05:46AM (#40944082)
Only if you remember, which you, or someone else, is bound to not eventually
Re:Enums in Go by dgb23 on Friday July 12, 2024 @08:10AM (#40944793)
But you're not adding variants without a reason? You want them to have some effect.

It's hard for me to think of an example where it would make even sense to "having to remember to handle the variant" rather than "handling the desired effect of the variant".

Re:Enums in Go by K0nserv on Friday July 12, 2024 @08:25AM (#40944882)
People are stressed, get distracted, are tired, don't have complete knowledge etc. This is kind of like arguing that null pointers aren't a problem, you "just" have to check all usage of the pointer if you make it null. In practice we know solutions like this don't work
Re:Enums in Go by rty32 on Friday July 12, 2024 @06:37AM (#40944307)
added that every switch/if should handle this exhaustively. For any project with more than a few dozens of files, it is basically impossible to remember all the downstream code that uses the enum -- you have to track it down, or better, let compiler automate check all usages
Re:Enums in Go by weavie on Friday July 12, 2024 @08:56AM (#40945108)
Huge codebase. It was handled in 13 places, but they missed the 14th.