lua-users home
lua-l archive

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

Would anyone like to comment on the behavior of this code? It prints "local x" and "nil", which is probably correct, but odd. I understand that "load()" compiles code in a global context, but when I have the output of string.dump() its not really being compiled again, is it? It's just packaged VM bytecodes. Given that, what happens to the upvalues? The ref manual for 5.2 simply says "with new upvalues" when a dumped function is loaded, but makes no mention of what this means, and of course in the code sample there ARE no upvalues to bind to the function anyway.

x = "global x"

	local x = "local x"
	function foo() print(x) end

sf = string.dump(foo)
f2 = load(sf, "", "bt", _ENV)