[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: In praise of 'nil' (Was: Proposal for table length operator
- From: Dirk Laurie <dpl@...>
- Date: Wed, 15 Dec 2010 09:31:57 +0200
On Wed, Dec 15, 2010 at 08:54:59AM +0200, Axel Kittenberger wrote:
> > What happened before the Big Bang? Nil.
>
> As empiricist I must say, no. We don't know. Might been Nil, might
> been something else. Currently no way to guess.
Exactly my point, actually.
"nil" in lua means "not one of the possibilities that we know
something about". There is no distinction between something unknown
and something non-existent. The failure to appreciate this fact is
what has sparked off the whole discussion on tables whose implementation
does make that distinction.
For example, if I say
for i=1,10 do print a[i] end
and some of those a[i]'s print 'nil', I am not given the information
of whether that 'nil' is stored as such in the array part, or is just
missing from the hash part. The "array part" of a table is simply a
convenient way of not explicitly storing keys that occur very often.
-- 'nil' makes no distinction between 'unknown' and 'non-existent'.
Dirk