[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: 5.2 work3 manual
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 19 May 2010 12:41:12 -0300
> > What do you mean by "the array part of a table"?
>
> That a table x (if constructed) would be the array part of a table t if:
>
> define n to be the greatest integer for which t has keys
> 1,2, ... ,n or zero if t has no such keys;
> then x has keys 1,2, ... ,n and x[i] == t[i] has the value true for
> i = 1,2, ... ,n or else x is {}.
>
> What I mean by "has keys" troubles me in the light of the fact
> that if x = { } and y = { nil } then x[1] == y[1] is true.
> Yet x has no keys, whereas y has 1 as a key. So there appears to
> be no way semantic way of testing "having the same keys" -
> one is appealing to what is happening "under the hood".
In Lua, the only sensible definition for "t has no key y" is "t[y] is
nil"; otherwise all tables have all keys. In your example, 'y' has no
keys (exactly as 'x').
-- Roberto