lua-users home
lua-l archive

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


> It is pretty interesting that access tbl[nil] is allowed,
> while setting it is not.

Access to tbl[nil] must be allowed: otherwise "print(xxx)" would give an
error, not nil. That's the whole point of nil being the default value of
global variables and absent table entries (which are the same thing).

Setting tbl[nil] is a different matter because it probably comes from
a programmer error. On the other hand, a case can be made for allowing
it and then return that value when accessing tbl[nil]. So the default
behavior would correspond to tbl[nil]=nil.