[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: lexical scoping confusion
- From: "Russell Y. Webb" <rw20@...>
- Date: Mon, 7 Apr 2003 11:41:30 -0700
I've managed to get confused about lexical scoping and am away from my
normal computer so I can't test this out. What happens if you return a
subfunction that accesses local variables in the outer function's
scope? Something like this:
function outer()
local x = 0
function inner()
x = x + 1
print(x)
end
inner() -- should print "1"
return inner
end
x = 12
f = outer()
f() -- what does this do? runtime error?
print(x) -- I assume this prints "12"
Thanks,
Russ