[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Speaking of tables [Was: Re: python like syntax for lua]
- From: Tuomo Valkonen <tuomov@...>
- Date: Sat, 14 Jun 2003 00:29:22 +0300
While this may have been discussed many times in the past, speaking
of positive integer table indices, I find the 'n' field annoying.
While it is debatable whether Lua itself should automatically keep
track 'n' (AFAIK only the table library uses it), why not at least
change the table library implementation to e.g. use a weak table to
store the information?
local ns=setmetatable({}, {__mode='k'})
function table.getn(tab)
if ns[tab]==nil then
-- Calculate n
ns[tab]=n
end
return ns[tab]
end
etc.
--
Tuomo