lua-users home
lua-l archive

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


2014-03-31 20:39 GMT+02:00 Thiago L. <fakedme@gmail.com>:

> local stringmetatable = getmetatable("")
> debug.setmetatable("", function(key)
> if key == "__metatable" then
> -- some magic
> else
> -- some other magic to get the env and do stuff (and then we use the stuff
> from the __metatable hack)
> end)

You can achieve this effect already:

local stringmetatable = getmetatable("")
debug.setmetatable("", setmetatable({},{
__index = function(key)
if key == "__metatable" then
 -- some magic
else
-- some other magic to get the env and do stuff (and then we use the stuff
from the __metatable hack)
end}))