lua-users home
lua-l archive

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


Yes, but it may be slightly inconvenient:

Here is a helper function that creates an empty table where you can supply the parameters you want to create the table with:
function newtable(arraysize, hashsize)
    return loadstring("return {" .. ("nil,"):rep(arraysize) .. ("[0]=nil,"):rep(hashsize) .. "}")()
end

(If used in practice, it should probably have a cache for combinations of arraysize and hashsize)

On Fri, Mar 13, 2009 at 3:30 PM, Luís Eduardo Jason Santos <jasonsantos@gmail.com> wrote:
Are you saying we already have a way of doing that?

Luís Eduardo Jason Santos



On Fri, Mar 13, 2009 at 9:24 AM, Peter Cawley <lua@corsix.org> wrote:
The Lua bytecode does encode the two arguments to createtable in the
appropriate opcode.