[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Should NaN be false? (Was: Re: simple question about NaN ...
- From: Axel Kittenberger <axkibe@...>
- Date: Wed, 23 Feb 2011 11:05:10 +0100
> There are three options.
> 1. NaN is true.
> 2. NaN is false.
> 3. Trying to convert NaN to boolean is an error.
> Option 3 is expressly designed out of Lua: everything must be
> convertible to boolean. There are pros and cons to 1 and 2:
> Pro 1: type(NaN)=='number'
> Con 1: but NaN means 'not a number'
> Pro 2: all situations in which NaN's arise are exceptions
> Con 2: it is not the status quo
Con2: nil as implizt false is considered an error, and doing more of
the same just makes it worse?
I dont know :)
You know that I secretly do not favor implicit booleans. But NaN would
fit in the picture with nil well.
Other possible issues, NaN is only available on Lua systems that are
compiled with floating points as numeric. I don't remember, because my
programms never devide by zero :) but what does an integer division
yield by default. Signal and if uncatched termination of the programm?
I'd also have some sympathy to have a special global table __falsevals
or so, for which all keys are considered false, so coders can make it
mean what they want. Only downside, you cannot put nil in or not into
it to signal if you want nil to be implciitly false or not.
Or better maybe, how about the possibility of a global meta function,
that is called everytime there is an implicit global? So you can make
it mean whatevery you want.