[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lists with nil play nice for Lua 5.2
- From: roberto@... (Roberto Ierusalimschy)
- Date: Fri, 3 Aug 2007 16:24:38 -0300
> The VM maintains n internally. This can have either a set value or an
> unset value.
This 'n' would increase the memory needed to store each table.
> 'Array part of the table' means <= n.
The internal "array part" of a table has a different meaning in Lua; it
means smaller than its "array size". The "array size" is the real
size of the array. It is not (and cannot be) 'n'. (We cannot grow it
one by one.) But let us assume this definition for "array part".
> - - when writing a non-nil element to the array part of the table, n
> does not change.
That would demand a new test when writing an element to the table (to see
whether the key is in the array part).
> - - when writing a nil element at index i, n becomes i.
Again this demand a test at each writing, to know whether the element
being written is nil.