lua-users home
lua-l archive

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


> 
> On Jan 8, 2010, at 12:10 AM, Paul Moore wrote:
> 
> > I thought "in" was lexical, so that the names in Test would *not* be
> > looked up in anEnvironment. You seem to be assuming that "in" uses
> > dynamic scope.
> 
> Right, this is indeed my assumption, i.e. a dynamic scope much akin
> to, well, get/setfenv... Pure speculation though :)
> 
> If it's not, then, well, hmmm, I'm a bit at a loss about the
> usefulness of that mysterious new "in" clause. Oh, well... will see
> how this pans out once more details leak out of Rio.

Note that get/setfenv does not have dynamic scope either. If a function
is *defined* inside a function with a setfenv, the new function inherits
this environment. The same is true for the new lexical environment. A
function *defined* inside a "in env do ... end" will be created with
environment 'env'. A setfenv (and an lexical environment) has no effect
at all over functions *called* in that environment.

>From the point of view of changing your own environment, setfenv and
lexical environments are practically equivalent.

-- Roberto