Ask HN: What should an undefined variable evaluate to?
I think most (all?) compiled languages evaluate to a compilation error.
As for NodeJS, I thought it would evaluate to `undefined`, but it seems to consistently throw a `ReferenceError` for version 20.
What's the result for other languages?
2 comments
[ 0.26 ms ] story [ 12.2 ms ] threadIn the IEEE 754 floating point definition, there are specific values for errors: mathematically undefined, division by zero, overflow, underflow, and inexact. These MUST be implemented in hardware to meet the specification.
But overall, having dedicated "error modes" seems to be the preferred route.
Thanks for the reply!
I wasn't aware of the VAX series of computers, successors of the PDPs. I knew Unix was first written on a PDP-11. Also wasn't aware of the hardware requirements for floating points.