[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: setfenv/getfenv
- From: Wim Couwenberg <wim.couwenberg@...>
- Date: Tue, 12 Jan 2010 19:29:40 +0100
I asked this before, but, did you consider to use a *named* upvalue
for the environment. Something like
in c = <expr> do ... end
where globals in the "..." part are looked up in the upvalue c. This
has the advantage that you can swap the environment of the entire
block at once:
local setenv
in c = <expr> do
<some code>
function setenv(x)
c = x
end
end
Calling setenv with a new table will now swap the environment of all
functions that are created in the block.
Bye,
Wim