[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Let's not break existing scripts.
- From: Matthew Frazier <leafstormrush@...>
- Date: Thu, 10 Nov 2011 15:44:06 -0500
On Nov 10, 2011, at 13:06 , Duncan Cross wrote:
> On Thu, Nov 10, 2011 at 5:58 PM, Petite Abeille
> <petite.abeille@gmail.com> wrote:
>>
>> On Nov 10, 2011, at 6:20 PM, Peter Cawley wrote:
>>
>>> It is also impossible to write setfenv in 5.2 in such a way as to work
>>> with bytecode chunks whose debug information has been stripped.
>>
>> Why? _ENV is always the first upvalue, no? No need to look it up by name, no? Its position will suffice, no?
>
> No, no and no. :)
>
> _ENV is only the first upvalue for a function that was compiled from a
> top-level source code chunk. Functions *in general*, i.e. also
> including functions defined inside a chunk or other function, may have
> _ENV at a different position, or even not at all.
Would it be possible for the compiler to ensure that _ENV is always the first upvalue?
Thanks,
Matthew Frazier
http://leafstorm.us/