lua-users home
lua-l archive

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


On Fri, Jul 16, 2010 at 12:01 AM, Miles Bader <miles@gnu.org> wrote:
> The implementation suggested by Roberto looks quite useful, is optional,
> and would be off by default for backward compatibility.  So what's the
> problem, exactly?

IMHO it's kind of ugly/clunky and feels like a band-aid to me, but I
mainly just use Lua embedded within a host application, so I could be
missing something. When I write small utility libraries, I pretty much
create my own "environment" table and return that from the chunk. My
feeling is that it would be simplest if this were the default, and
everything within a chunk was always executed within a new
environment. Then I wouldn't have to worry about accidentally
cluttering the calling code's space at all.

I realize someone said this is already possible, but it makes sense -
to me, at least- to make this an actual part of the language. For
backwards compatibility, require() can just import the symbols from
the loaded module into the calling code's environment. This means
another library function can be supplied that just returns the new
environment.

~Jonathan