Re:What I'd like to see in Go 2.0
by masklinn on Friday February 04, 2022 @11:27AM
(#30208911)
Oooor the language can have proper type-safe enumerated types of some sort, and if you're in a domain where that's an issue you don't use them.
[ Parent
| on HN ]
Go is focused on the distributed systems domain though. It's fine, even desirable, to have languages focused on particular domains, that make design decisions based on the constraints of the domain. In this domain, closed enums are footguns with costly consequences if you get it wrong.
As someone that doesn't work in that domain, could you give a short example?
Re:What I'd like to see in Go 2.0
by closeparen on Friday February 04, 2022 @08:06PM
(#30215915)
You push Thrift clients out into the world expecting to a certain API field to be typed according to a 3-element enum. You add a 4th element to support a new feature in a new client. If you ever accidentally serve this 4th element to an old client, it will crash on deserialization. Bonus points if the client is old enough that it's not part of your testing regime anymore.