lua-users home
lua-l archive

Re: setfenv/getfenv

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 2010年1月12日, Enrico Colombini wrote:
>
> local t = {}
> local s = "function f() a = 3 print(a) end"
> local chunk = assert(loadstring(s))
> -- chunk is currently executed in the global env,
> -- I'd like to execute it in 't'
> in t do chunk() end -- no effect in 't'
 local t = {}
 local s = "function f() a = 3 print(a) end"
 local chunk = assert(loadstring("in ... do "..s.." end"))
 chunk(t)
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.

AltStyle によって変換されたページ (->オリジナル) /