How NaN Breaks Python and Lua Language Design Assumptions
Two Case Studies of NaN
I discovered two surprising cases where IEEE-754 NaN values break implicit assumptions in programming language design. In Python, list equality checks fail because NaN does not equal itself, violating reflexive rules. In Lua, numerical for-loops behave unpredictably when NaN is used as a limit or step, leaking internal comparison logic. These oversights show how weird NaN behavior can silently corrupt language semantics.
NaN is weird, and that means other things behave weirdly with it.
- fragmede
Wat.
I wish there were a recent remake of it.
- ColinWright
- whatever1
Just store what you mean to store for gods sake. We have been fighting with over-designed bs for decades.
Zero is not absence of a value. It has a value, it happens to be 0. Same for undefined/infinity. They exist.
Let the hardware engineers figure out an efficient way to deal with it. If it costs more, well if we add up all of the costs of bugs due to zero/null conversions, maybe it was worth it.