lua-users home
lua-l archive

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


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.