lua-users home
lua-l archive

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


Thanks for the update, Roberto.

The discussion left me convinced that closure environments and lexical environments are conceptually incompatible, and Lua needs to cleave to one or the other. As a writer of a "Lua-in-Lua" sandbox, I still have a few thoughts and questions:

Does this mean that you can supply any value to _ENV, as long as it provides __index and __newindex metamethods as required?

I still sort of favor an environment stack set through a construction like "in env do ... end" because it gives the code on the outside control over whether or not the code on the inside can see or replace the environment itself, or only its contents. How can I restrict a chunk of code from interacting with _ENV directly, short of refusing to load source code that contains the "_ENV" name?

That said, I'm pretty sure I could make my code work safely within the parameters as you've outlined them.

Nevin

On Feb 24, 2010, at 6:38 PM, Roberto Ierusalimschy wrote:

> After that long discussion about setfenv/getfenv, we are convinced
> that both functions should belong to the debug API. Both clearly break a
> function's abstraction, tampering with the "original meaning" of the
> function. They are clearly quite similar to getupvalue/setupvalue,
> as both groups manipulate the external variables of a function.