lua-users home
lua-l archive

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


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]