[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: scope hiding suggestion
- From: Roberto Ierusalimschy <rieru@...>
- Date: Mon, 11 Feb 2002 14:03:50 -0600 (CST)
On Mon, 11 Feb 2002, Lucas Ackerman wrote:
> Ok, so that is already doable, but it's not what I'm asking for. In 4.0,
> you can get away with just hiding globals, and in your case you
> don't need to do this from within Lua. But if someone does want to
> do this within Lua (I can think of any number of reasons -
> demarshalling object references, more flexible sandbox setup, etc),
> with a more recent build that uses lexical scoping, then they need to
> be able to hide the enclosing scope, which was the real point of this
Lexical scoping only works for things literally defined inside the
scope. If a function is not literally written inside the scope of a
local variable, it does not have access to that variable.
As an important particular case, strings run through `dostring' do not
have access to the scope where `dostring' is running:
dostring("a=a+1") -- this `a' is global!
So, unless the code you want to protect is literally inside your program,
nothing changes from 4.0 to 4.1.