lua-users home
lua-l archive

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


2014-04-09 7:53 GMT+02:00 steve donovan <steve.j.donovan@gmail.com>:
> On Tue, Apr 8, 2014 at 10:16 PM, Peter Melnichenko
> <petjamelnik@yandex.ru> wrote:
>> What's inconsistent, in my opinion, is that an error is not thrown when
> _getting_ a field using those non-retrievable keys, which may result in
> thorny debugging problems as well.
>
> That's the point that makes sense - we agree that nil is not a valid
> table index, and it should be an error for _both_ getting and setting.

The word 'valid' is misleading. Nil and NaN are invalid for setting,
since the operation cannot be done, but merely futile for getting.
Not invalid.

Getting means: I give you this Lua value, find me a key equal to that,
and return the corresponding value. If there is no such key, return nil.
Since nil or NaN could not be used for setting, you will never get
anything except nil, but that is still the correct value to return.