[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: setfenv/getfenv
- From: Francesco Abbate <gslshell@...>
- Date: Tue, 12 Jan 2010 18:17:11 +0100
2010/1/12 Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>:
>> That on the other side looks horribly un-lua-like to me (and unefficient
>> if the code in question is long enough), also this wont work for loadfile().
>
> You could use the plain load function with a suitable function that does
> the wrapping by sending "in ... do " at the beginning and " end" at the
> end, with no need for concatenation.
For me this kind of solution is ugly and it clearly reveal that we
have a fundamental problem with the new proposed schema.
I will try to rationalize the complaints. Many people complaints about
the removal of getfenv/setfenv because:
1) you lose the ability of sandboxing a script that you load
2) with userdata you are losing the opportunity of:
- let the Lua GC be aware of cross dependencies between userdata objects
- let a userdata store some Lua data.
The answer to this kind of criticism is:
1) you can simulate the sefenv for sandboxing by using the "in" syntax
to construct on the fly a new string that you pass to loadstring =>
this is ugly and totally not-elegant and not efficient
2) the getfenv/setfenv will remain available in the C API => this is
ambiguous because either they are first class ordinary functions
either they are special debug functions.
Because of these reason I believe that the Lua development team should
come back through theirs steps and search another approach to solve
the problem Roberto was talking about.
This is my point of view, I hope it is helpful.
Francesco