lua-users home
lua-l archive

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


Hi

Why can't we use something like this in Lua ?

local a = 1
function b()
	local c = function()
		print(%%a)
	end
end

It is surely strange, but by the upvalues definition (the constant value of
a variable in the moment the function was defined (right??)) shouldn't
constructions like this be possible ?

... or function c only gets defined when we call b ?


couldn't lua handle this automatically ?:

local a = 1
function b()
local a = %a
	local c = function()
		print(%a)
	end
end