如果我有一个Lua函数f
,我可以使用f
函数查看debug.getupvalue
闭包中的所有upvalues。同样,如果我有一个文件foo.lua
,我可以先查看upvalues,然后先使用foo = loadfile(foo)
debug.getupvalue
,就像使用f
一样。如果我require
foo.lua
在那里,我可以弄清楚foo.lua
关闭的上升值是什么?
答案 0 :(得分:2)
The module loaded by require
is not preserved by require
's standard loaders. Only the return value from the execution of that module is preserved.
So while you can inspect any upvalues for any function exported by the module, you cannot inspect upvalues that are only accessed by non-accessible functions.