lua-users home
lua-l archive

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


On Tue, 12 Jan 2010, 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.