lua-users home
lua-l archive

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


On Thu, Jul 23, 2009 at 00:15, Luiz Henrique de
Figueiredo<lhf@tecgraf.puc-rio.br> wrote:
>> 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).

Sorry, I must be dumber than usual today, cuz I don't get it. I
thought print(xxx) tries getfenv(1)['xxx'], and not getfenv(1)[nil].
Same for nil being the default value for globals (which are always
string keys since they have to be valid identifiers).