lua-users home
lua-l archive

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


> 
> 
> 
> >>btw, I notice that there is a new keyword, "undef", not mentions in manual,
> >>is that just a undocumented feature or the doc just not the latest?
> Why is the new "undef" not used the other way round:
> 
> A[2] = nil removes the entry from the table
> A[2] = undef  puts a value in A[2] that reads 'nil'
> 
> That would keep compatibility with Lua 5.3 and older

We thought about something like that.

The problem is neither 'a[t]=nil' nor 'a[t]=undef', but 'a[t]=x' when
'x' happens to be nil. This is what creates surreptitious holes in
tables that leads to all the problems with '#t'. In the end, we would
have something like this:

x = nil; t[1] = x;    -- adds element
         t[1] = nil;  -- remove element

Rather strange...

-- Roberto