lua-users home
lua-l archive

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


	Hi David

	I think I didn't understand your problem properly.

So we end up with an environment that has lots of userdatas that
get used for subsequent Lua code.
	This environment is reused by different executions of different
scripts?

if the code that I am executing does a require"somemodule" then
the environment of the functions in the module are set at require()
time, that is when the code is loaded.  I have no obvious way
of resetting the environment of the required()ed functions as my
transient environment changes.
	You are reusing the functions of the module but changing its
environment?

One option would be to use (in the require()ed code something like
setting the environment to have __index and __newindex to
functions that somehow dynamically find the environment of the
caller.

 setfenv(1, setmetatable(env, {_index = function_that_finds_env()}))
	This seems to be very difficult to implement, isn't it?
	If I understand it correctly, this problem seems to be similar
to the one that we faced with VEnv in Lua 5.0.  We could redefine module()
to use with Lua modules, but we couldn't redefine the behavior used by C
modules so we have an environment that doesn't work with required binary
libraries.

	Tomas