[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua registry, environment, and threads.
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 8 Jan 2010 11:00:54 -0200
>
> 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
- References:
- Re: Lua registry, environment, and threads., Roberto Ierusalimschy
- Re: Lua registry, environment, and threads., Christian Tellefsen
- Re: Lua registry, environment, and threads., Roberto Ierusalimschy
- Re: Lua registry, environment, and threads., Mark Hamburg
- Re: Lua registry, environment, and threads., Patrick Donnelly
- Re: Lua registry, environment, and threads., Roberto Ierusalimschy
- Re: Lua registry, environment, and threads., Leo Razoumov
- Re: Lua registry, environment, and threads., Petite Abeille
- Re: Lua registry, environment, and threads., Paul Moore
- Re: Lua registry, environment, and threads., Petite Abeille