[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua registry, environment, and threads.
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 7 Jan 2010 17:23:39 -0200
> What are the expected use cases for in env do ... end? As I'm
> understanding it, it basically just saves writing env.name for various
> reads and writes at the expense of losing access to other globals
> unless they are provided by env. So, it could be implemented as:
>
> do
> local _env = env
> ... code with global accesses modified to reference _env ...
> end
>
> Is this a correct understanding?
Yes. This is exactly what the compiler does.
> That would seem to make sense as a syntactic replacement for some of the
> setfenv tricks but those tricks seem like tricks much of the time as
> opposed to particularly clean ways to write things. See the discussions
> about issues with the module function and package.seeall, for example.
Well, I particularly live well with 'module' (e.g., the package 're'
from LPEG uses it without the seeall option). It is far from perfect,
but it seems a good balance.
-- Roberto
- References:
- 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., Mark Hamburg
- Re: Lua registry, environment, and threads., Mark Hamburg
- Re: Lua registry, environment, and threads., steve donovan
- Re: Lua registry, environment, and threads., Roberto Ierusalimschy
- Re: Lua registry, environment, and threads., Mark Hamburg