lua-users home
lua-l archive

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

How about extending the '__mode' metatable key for fixed size arrays? Say 'f' in addition to the current 'k' and 'v' for weak tables. If 'f' is set, the array part of the table is never shrunk or grown and '#' is simply the fixed size of the array part. You assign the fixed size when creating the table either by initialising contiguous integer values or with a new Lua library function which surfaces the sizing parameters in the lua_createtable 'C' API. Integer keys greater than the fixed size are treated like any other key and stored in the hash part without affecting '#'.