[Python-ideas] Suggestion: Extend integers to include iNaN

Michael Selik mike at selik.org
Sat Sep 29 03:18:04 EDT 2018


On Fri, Sep 28, 2018 at 11:32 PM Steve Barnes <gadgetsteve at live.co.uk> wrote:
> One of the strengths of the IEEE float, (to set against its many
> weaknesses), is the presence of the magic value NaN. Not a Number, or
> NaA, is especially useful in that it is a valid value in any
> mathematical operation, (always returning NaN), or comparison, (always
> returning False). In functional programming this is especially useful as
> it allows the chain to complete after an error while retaining the fact
> that an error occurred, (as we got NaN).

The inventor of "null reference" called it a billion-dollar mistake
[0]. I appreciate the Zen of Python's encouragement that "errors
should never pass silently." Rather than returning iNaN, I'd prefer my
program raise an exception. Besides, you can use a None if you'd like.

[0] https://en.wikipedia.org/wiki/Tony_Hoare


More information about the Python-ideas mailing list