lua-users home
lua-l archive

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

On Fri, Feb 19, 2010 at 9:47 AM, Geoff Leyland
<> wrote:
> Oh, right, well that's ok then.  Thanks!

Like so:

Lua 5.2.0 (work2)  Copyright (C) 1994-2010, PUC-Rio
> fn = loadin({x=1,y=2},"return x+y")
> = fn()

> Sandbox?  Maybe I'm naive in thinking that most of the work I do is unlikely to suffer security issues, but in that particular case, if you can change the the config file, you can just go and change the script that's reading it.

Sorry, I was picking up on someone remarking on the io dependency
needed. Point being that you can write a version of dofile that works
as expected.

Now, here is something that I expected to work, but no:

-- test1.lua

-- dofile.lua
local loadfile = loadfile
local fun
in {x=1,y=2,print=print} do
    fun = loadfile "test1.lua"

But (alas) the created function is not given the environment!

steve d.