lua-users home
lua-l archive

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


> On Oct 6, 2015, at 11:41 AM, Soni L. <fakedme@gmail.com> wrote:
> 
> 
> 
> On 06/10/15 03:05 PM, Tim Hill wrote:
>>> On Oct 5, 2015, at 3:55 PM, Soni L. <fakedme@gmail.com> wrote:
>>> 
>>> [...]
>>> 
>> [...] For “interior” functions that are extracted using something like string.dump(), the upvalue used for _ENV, if any, is arbitrarily assigned by the compiler (and not discoverable by examination of the bytecode).
>> 
>> —Tim
>> 
>> 
>> 
> And that's precisely why I want load() to be able to set ANY upvalues, not just the first.
> 
> See https://github.com/SoniEx2/loadx
> 
> -- 
> Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.
> 
> 

But how will you know which value to assign to which index? Assignment of (named) upvalues to indices is done at compile-time and can change arbitrarily with any (potentially trivial) change to the code. This means that any call to load(…) is tied to a single specific compiled instance of a function, and will break should that code change (and with no easy way to detect this).

—Tim