lua-users home
lua-l archive

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


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--