lua-users home
lua-l archive

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




2010/5/20 Roberto Ierusalimschy <roberto@inf.puc-rio.br>
> It's a question of how much sugar a person needs, but
>
> in t do x = 10; y = 20 end
>
> seems easier to read than
>
> do local _ENV = t;  x = 10; y = 20 end

Surely it is.

In these discussions in the list, sometimes it looks like people are
changing environments all the time, in all sorts of code. I may be
very wrong, but my impression is that changing the environment is
seldom done, mainly (only?) in the setup of a module or when running
untrusted code. I would like it to look "ugly", to be easily seen
and found (e.g., "/_ENV"), not to look like "code as usual".


I agree, changing environments is black art.
This line [[setfenv(level, M)]] is uniq and hidden in the
depth of my object library (http://github.com/fperrad/lua-Coat).
The environment is modified when I create a class.
The user of the library don't see/know this black art.

We only need that it is possible.
It is not a problem if it looks "ugly".

François
 
-- Roberto