4 ms·
wat?
by rweichler 9y ago
wat?
- pygy_ 9y agoWith setfenv, the environment definition is lexical by default, but if you change the environment of the parent after creating a child function, the environment of the child doesn't change. You must `setfenv` the child as well. With _ENV, it is fully dynamic, and can be changed "at a distance". Also: > function foo() >> local function bar() return a end >> setfenv(1,{a=4}) >> return bar >> end > a = 9 > =foo()() 9