[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: setting _ENV in Lua 5.2 when loading a file...?
- From: Miles Bader <miles@...>
- Date: Thu, 10 Nov 2011 19:50:56 +0900
Jerome Vuarand <jerome.vuarand@gmail.com> writes:
> local chunk = loadfile(filename)
> debug.setupvalue(chunk, 1, environ)
> chunk()
Er, imagine there's an implicit "without using the debug package" in
my question...
>> Also, what about from C? lua_load there _doesn't_ take an env
>> parameter, so what should we do then...?
>
> if (luaL_loadfile(L, filename))
> return lua_error(L);
> lua_getglobal(L, "environ);
> lua_setupvalue(L, -2, 1);
> lua_call(L, 0, 0);
Hmm, so... just like setfenv... :]
Thanks,
-Miles
--
If you can't beat them, arrange to have them beaten. [George Carlin]