Re: tables holding nil
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: tables holding nil
- From: Jim Whitehead II <jnwhiteh@...>
- Date: 2009年7月22日 22:17:03 +0100
On Wed, Jul 22, 2009 at 10:15 PM, 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).
>
> 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.
Thanks for the clarification, that makes perfect sense.
- Jim