[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: setfenv/getfenv
- From: Alexander Gladysh <agladysh@...>
- Date: Tue, 12 Jan 2010 19:09:26 +0300
On Tue, Jan 12, 2010 at 18:25, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
> I will try to answer the sereval requests for our rationale for the
> removal of setfenv/getfenv.
Thank you!
<...>
> We tried to restrict such uses. Basically, if you create a new function,
> you can set its environment. Otherwise, the function itself should be
> responsible for its own environment (using lexical environments).
> Most uses easily fit this setting. Others may need extra work. For
> instance, more than one user talked about loading a piece of code once
> and running it whith different environments. I may be wrong, but
> I think the following code does it (suggested by lhf):
> code = "string with the code to be loaded"
> f = loadstring("in ... do " .. code .. " end")
This approach is not compatible with the case when "code" is in bytecode form.
Is bytecode form considered a second class citizen? (Security issues aside.)
Alexander.