[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: a new proposal for environments
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 24 Feb 2010 21:25:02 -0300
> I guess loadstring() would use the _ENV in the lexical scope of its
> call site?
Just follow the rules (1 & 2). loadstring is a specific form of load. It
will enclose the string with a new "local _ENV=<some value>", where
<some value> is the global table.
Lexical scope means that _ENV is only visible by code that is lexically
in its scope.
Of course, you can write "loadin(_ENV, string)" and then make the
string share the lexical scope of its call site. But you must pass _ENV
explicitly; nobody can access it outside its lexical scope (except using
the debug API).
-- Roberto