lua-users home
lua-l archive

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


John Belmonte <john@neggie.net> 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.

I agree. nil as a perfectly sensible value in its own right as compared
to nil as meaning undefined is a certain source of confusion.

However, as others have remarked, I am not sure whether there's a
elegant solution that's also backward compatible.

-- 
cheers  thomasl

web : http://thomaslauer.com/start