Code: Select all
for i, _if in ipairs(ifs) do
for k, e in pairs(_if) do
if k ~= "init" and k ~= "_NAME" and k ~= "_M" and k ~= "_PACKAGE" and k ~= "new" then
c[k] = e
-- print(("caching interface value %s (%s) from %s to %s"):format(k, tostring(e), _if._NAME, c._NAME))
end
end
end
setmetatable(c, {__index=base})
Code: Select all
local handler = function(self, k)
local result
result = base[k]
if result ~= nil then
return result
end
for i, _if in ipairs(ifs) do
result = _if[k]
if result ~= nil then
return result
end
end
end
setmetatable(c, {__index=handler})
I guess there could have been a reason to prefer caching over this method...