lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Ahhh, the classic argument. Nil and zero are not the same, zero
represents the lack of quantity of something being counted, nil
represents the lack of data. In some areas of computing (such as the
database work I do) this is a major difference. In my mind,
tonumber(nil) should return nil.

Timothy

On Mon, Apr 27, 2009 at 8:32 AM, Mike Crowe <drmikecrowe@gmail.com> wrote:
> Hi folks,
>
> I was briefly caught by doing this test:
>
>   if tonumber(something) > 0 then
>      ...
>   end
>
> with something=nil.
> I'm not advocating a change, but what's the thought-process behind this
> behavior?  Wouldn't you consider the numeric value of nil to be 0?
>
> Mike
>



-- 
“One of the main causes of the fall of the Roman Empire was
that–lacking zero–they had no way to indicate successful termination
of their C programs.”
(Robert Firth)