Skip to content

Instantly share code, notes, and snippets.

@katlogic
Last active August 29, 2015 14:00
Show Gist options
  • Save katlogic/c6b3c961a1a71bde67b1 to your computer and use it in GitHub Desktop.
Save katlogic/c6b3c961a1a71bde67b1 to your computer and use it in GitHub Desktop.
local funtab=setmetatable({}, {__mode="k",__index=function(t,k) t[k]={}; return t[k] end})
debug.setmetatable(function() end, {
__index=function(f,k)
return funtab[f][k]
end,
__newindex=function(f,k,v)
funtab[f][k] = v
end
});
local function this()
return debug.getinfo(2,"f").func
end
function f()
print(this().x)
end
f.x = 1234
f()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment