[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: setfenv/getfenv
- From: Tony Finch <dot@...>
- Date: Tue, 12 Jan 2010 17:39:10 +0000
On Tue, 12 Jan 2010, Enrico Colombini wrote:
> Tony Finch wrote:
> > local t = {}
> > local s = "function f() a = 3 print(a) end"
> > local chunk = assert(loadstring("in ... do "..s.." end"))
> > chunk(t)
>
> Besides, it could be convenient to be able to execute a chunk in different
> environments without reloading it.
If you load the chunk as above then you can just do
chunk(env1)
chunk(env2)
Tony.
--
f.anthony.n.finch <dot@dotat.at> http://dotat.at/
GERMAN BIGHT HUMBER: SOUTHWEST 5 TO 7. MODERATE OR ROUGH. SQUALLY SHOWERS.
MODERATE OR GOOD.