[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Explanation about environments asked
- From: Tobias Kieslich <tobias@...>
- Date: Thu, 10 Dec 2009 00:32:52 -0800
Hi,
I'm trying to wrap my head around environments (setfenv and co) and came
across a behaviour for whih I didn't find an explanation.
code:
a = 10
local t = {print=print,a=1,b=2}
setfenv(1,t)
print(a,b)
result:
1 2
That does make sense to me, but if the global a instead get's declared
local the result seems weird to me.
code:
local a = 10
local t = {print=print,a=1,b=2}
setfenv(1,t)
print(a,b)
result:
10 2
what happened to the a that got declared in t? Thanks for any pointers,
-T