lua-users home
lua-l archive

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


> The table 'a' will have an array part of length 0, and 'b' will
> have an array part of length 1 when you say 'b[1]=2'.  From ltable.c:
>     The actual size of the array is the largest `n' such that at
>     least half the slots between 0 and n are in use.
> The array part will therefore stay at length 1 when you say "b[1000]=1".
> 
> When you say "b[1]=nil" the array part should drop back to length 0,
> according to that statement, but whether the memory already allocated
> is freed just yet I don't know.
Hmm... after the execution of the code the tables a and b have both a entry with index 1000 and the value of 1. Why should the array part be 0? The largest `n' would be in this case 1000, so the size of the array part for both tables would be also 1000 or not?
i.e. the memory usage of the tables e and f would be different ?
---
e = {10000 = "foo")
f = {1 = "foo"}
---
--
Wladimir Krawtschunowski
Software developer

Vectron Systems AG
Willy-Brandt-Weg 41
48155 Münster, Germany
Tel.: +49/251/28 56-0

--- 
Vectron Systems AG, Willy-Brandt-Weg 41, 48155 Münster, Germany, Phone +49-251-2856-0, Fax +49-251-2856-560, 
Amtsgericht Münster HRB 10502, Vorstand / Board of Management: Jens Reckendorf, Thomas Stümmler, 
Aufsichtsrat / Supervisory Board: Christian Ehlers (Vorsitz / Chairman)