[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: setfenv (was Re: tuples)
- From: Wim Couwenberg <w.couwenberg@...>
- Date: Fri, 16 Sep 2005 22:25:14 +0200
> We could write modules like this:
> in module(modname) do
> ...
> end
Absolutely! What I liked about the idea is that a function environment
becomes "just" an upvalue. If you change the environment (as in the
"setfenv" example of Rici) it simultaneously changes the environment
of all functions in a module. I wouldn't mind getting rid of
(s/g)etfenv, especially on stack levels. (That would also make the
environment "private", i.e. more protected.)
Maybe loadfile (and loadstring) would need an extra (optional)
environment argument such that
loadfile(f, name, env) -- or loadfile(f, env [,name]) ?
would basically do
in env do
-- chunk in file "f" goes here
end
Mark suggested something similar I believe? Then both modules and
"sandboxing" are covered, two of the main applications for
environments.
--
Wim