Skip to content

Enumerated types can get in the way of fast and safe iteration

nightlight.conductor.com
3 pointsiamchrisle2 comments
On HN

Comments

Default cases are your friend.

Personally, my most wanted feature for enums in general is a way to distinguish between "final" enums - that are intended for enums that cannot change, and a modifiable enums, where they can change and a lack of default case throws a syntax error.

Unfortunately, there is no way to enforce someone not changing a "final" enum.

Default cases can be helpful. Unfortunately, with generated serdes (as in Thrift, Avro, or Protobufs), you may not have control over the decoding or ability to customize the default case. For some of the details WRT Thrift in particular, there's a related discussion underway on the user mailing list now:

http://mail-archives.apache.org/mod_mbox/thrift-user/201311....

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.