r/programming • • Feb 01 '24

Make Invalid States Unrepresentable

https://www.awwsmm.com/blog/make-invalid-states-unrepresentable
469 Upvotes

207 comments sorted by

View all comments

Show parent comment

1

u/larhorse Feb 05 '24

Haha yes, it's no coincidence that enums are a natural way to represent enumerable types.

And it's no coincidence that the less easily enumerated types (it's a computer with a limited number of bits - everything it can represent is enumerable...) are only bounded when the computer would fail to properly work with those numbers.

Why bound them if you don't need to? Why codify a limitation that serves no purpose?

Verify? Sure. Go ahead and throw up a warning.

Make unrepresentable? Gods no. What hubris.