lua-users home
lua-l archive

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


Petite Abeille <petite.abeille@gmail.com> writes:
>> 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.

It looks to me like it just lets the user specify more conveniently what
happens when the compiler sees unknown variables -- i.e., right now if
the compiler sees an unknown variable foo, it just generates code to
look up "foo" in the surrounding function's fenv; with the new
construct, the compiler will presumably generate code to lookup "foo" in
the innermost environment ENV specified by "in ENV" instead.  It seems
like if there is no such surrounding construct, it will default to the
function's fenv like normal.

I think that's cool and it looks useful; what I object to is the removal
of setfenv/getfenv, since they seem to be useful for (non-debugging!)
things that this new construct can't do.

-Miles

-- 
Brain, n. An apparatus with which we think we think.