lua-users home
lua-l archive

Re: Lua registry, environment, and threads.

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


Leo Razoumov schrieb:
On 2010年01月09日, steve donovan <steve.j.donovan@gmail.com> wrote:
 (BTW, a safer 5.2 idom is:
 local loadstring = loadstring
 in {x = 1, y = 10} do fn = loadstring 'return x + y' end
 Given that loadstring is potentially a nasty function in a sandbox)
 steve d.
Can one do the following instead?
local fn = loadstring 'return x + y' --first compile the chunk for future use
in {x = 1, y = 10, print=print} do print(fn()) end -- 11
in {x = 2, y = 20, print=print} do print(fn()) end -- 22
--Leo--
Potentially I totally missed the point, but if isolation is the problem, what is with (untestet):
local fn = loadstring ' function(env) do' .. 'return x + y' .. 'end'
in {} do print(fn{x = 1, y = 10, print=print}) end -- 11
in {} do print(fn{x = 2, y = 20, print=print}) end -- 22
?
Frank

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