[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lists with nil play nice for Lua 5.2
- From: Gavin Wraith <gavin@...>
- Date: Sat, 28 Jul 2007 23:19:39 +0100
In message <46ABA94F.9030905@neggie.net> you wrote:
> Programming in Lua refers to nil in a list as a "hole", but that is from
> the perspective of Lua's table representation which cannot distinguish
> nil-valued from nonexistent keys. From the view of the list creator,
> why should either of the following be considered as having holes?
>
> x = { 2, nil, 'bar' }
> t = { 2 }; table.insert(t, nil); table.insert(t, 'bar')
>
> Clearly they are not sparse as constructed. Stepping back, a list is
> generally defined a series of values. Lua nil is a first class value--
> an incredibly useful one-- which should not render lists practically
> useless.
There is a long history of confusion, even in the purely theoretical
considerations of the semantics of type theories, about bottom
elements denoting undefined data, exceptions etc. The difficulty seems
to be that nil is being stretched to rather a lot of uses. The
introduction of boolean values in Lua freed nil from having to represent
false. Is it not conceivable that the user may need lots of different
kinds of nil? For example
nil (= undefined),
nil (= you can go ahead and garbage collect),
nil (= error condition),
nil (= please keep this slot ready till I get round to filling it)
might in some circumstance need to be discriminated, perhaps?
--
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/