Re: Function as metatable (metafunctions?)
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Function as metatable (metafunctions?)
- From: Dirk Laurie <dirk.laurie@...>
- Date: 2014年3月31日 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}))