lua-users home
lua-l archive

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



On 08/09/2006, at 7:10 AM, Gavin Kistner wrote:


local a = 10
function f( )
	print( a )
end

local a = 20
function g( )
	print( a )
end -- g

a = 30     -- no local here
print( a ) --> 30
f( )       --> 10
g( )       --> 30



The surprising part here is that the last one prints 30 and not 20. However it is consistent with my forward declaration problem.

The last "a = 30" must have modified the *most recently declared* local variable, hence f prints 10 but g prints 30.

- Nick