lua-users home
lua-l archive

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


On Sun, Dec 12, 2010 at 09:57:12PM +0200, Romulo wrote:
> Array with holes are not arrays in Lua, they are hash tables. That simple.
> 
> Thus, if t[ 1 ] is nil, then #t is zero, even if different
> implementations may give other results. Specially if others
> implementations give different results.
> 
> I wonder why people can't just accept it.
>
Maybe because some of them read the C API section of the Reference Manual, 
which says:
--[[
void lua_createtable (lua_State *L, int narr, int nrec);

Creates a new empty table and pushes it onto the stack. The new table has 
space pre-allocated for narr array elements and nrec non-array elements. 
This pre-allocation is useful when you know exactly how many elements the 
table will have. Otherwise you can use the function lua_newtable. 
--]]

Dirk