[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Function as metatable (metafunctions?)
- From: Dirk Laurie <dirk.laurie@...>
- Date: Mon, 31 Mar 2014 22:26:42 +0200
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}))