4 ms·
NaN is not necessarily an error. It might be fine. It depends on what you're doing with it. If NaN is invalid input for the next step, then sure why not treat
by nyeah 1y ago
NaN is not necessarily an error. It might be fine. It depends on what you're doing with it.
If NaN is invalid input for the next step, then sure why not treat it as an error? But that's a design decision not an imperative that everybody must follow. (I picture Mel Brooks' 15 commandments, #11-15, that fell and broke. This is not like that.)
- kccqzy 1y agoYes it is totally fine. I've seen code basically treating NaN as missing data as opposed to std::optional<double> or equivalent in your language. NaN propagates so this works like using such types as a monad.
- BlackFly 1y agoSure, not every runtime type error needs to panic your application, nor even panic a request handler, nor even result in a failed handling. That doesn't mean you didn't encounter an error though. Error doesn't mean fatal. The design decision isn't, "Was this a type error?" but, "What do I need to do about this type error?"
- deleted 1y ago[deleted]
- nyeah 1y ago“BRITANNUS (shocked). Caesar, this is a type error. THEODOTUS (outraged). How! CAESAR (recovering his self-possession). Pardon him. Theodotus: he is a barbarian, and thinks that the customs of his tribe and island are the definition of the float type.”