local function setlength (t, len)
local mt = getmetatable(t) or {}
setmetatable(t,mt)
mt.__len = function () return len end
end
^ Sean, are you referring to this type of solution? I am sure it would cover some bases.
The other solutions I can think of are:
1. Using pairs to find the largest numerical index of a table (slow to get length, but allows nil within the table)
2. Overriding __newindex to keep track of a max value. This enables 't[1000] = true' to cause '#t = 1000'. Could get hairy with removing values.