Posted 22 December 2012 - 06:59 AM
Methods in the title, respectively, set a function, or a table, to the __index field of a metatable.
This is inconsistent and non-standard behavior. Plus, I traced this to the following override in bios.lua:
Since users can bypass it by using the second method (however replacing the setmetatable version by the original has a wrapping cost), I ask why is this replacement here?
EDIT: maybe it's for changing one error to another, e.g. table->table->table… to function->function->function…. Why?
This is inconsistent and non-standard behavior. Plus, I traced this to the following override in bios.lua:
local nativesetmetatable = setmetatable
function setmetatable( _o, _t )
if _t and type(_t) == "table" then
local idx = rawget( _t, "__index" )
if idx and type( idx ) == "table" then
rawset( _t, "__index", function( t, k ) return idx[k] end )
end
local newidx = rawget( _t, "__newindex" )
if newidx and type( newidx ) == "table" then
rawset( _t, "__newindex", function( t, k, v ) newidx[k] = v end )
end
end
return nativesetmetatable( _o, _t )
end
Since users can bypass it by using the second method (however replacing the setmetatable version by the original has a wrapping cost), I ask why is this replacement here?
EDIT: maybe it's for changing one error to another, e.g. table->table->table… to function->function->function…. Why?