lua-users home
lua-l archive

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


> > 	I think this is another problem.  I was saying that with the
> > Virtual Environment you can do that.  In fact, we are doing this all
> > the time with CGILua: each new request has its own environment which
> > inherits the globals from the original environment.
>
> Tell me which possibility is your case, or point me to the magic I
> didn't understand.
>
> 1) The socket namespace is shared between scripts.
>    Problem: Unsafe. If one script changes it, the others will be affected.
>
> 2) Each script gets a cloned copy of the socket namespace.
>    Problem: Doesn't work. The functions in the cloned namespace will
>    ignore any change made to it, (PORT and PROXY, for instance).
>
> 3) Each script gets a fresh constructed copy of the namespace.
>    Problem: It's safe and it works, but might be too slow.
	It is almost the third one, but there is no COPY of the namespace.
There is another environment for each script.  Function require is redefined
to cache the loaded file (as a function); this function is executed in each
new environment (if required, of course).  Globals from the original env
are inherited.  You can take a look at CGILua 5.0 alpha 3 source, file
clmain/venv.lua.  I really don't know what performance you expect, but I
think this is not too slow...

	Regards,
		Tomas