[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Determining if _ENV is the first upvalue of a closure?
- From: Dirk Laurie <dirk.laurie@...>
- Date: Fri, 13 Mar 2015 10:12:31 +0200
2015-03-13 8:32 GMT+02:00 Tim Hill <drtimhill@gmail.com>:
> Yes, I know how to represent _ENV in the serialization as a placeholder.
> The problem is the code DOESN’T actually know if the closure has _ENV
> or not in the first upvalue. Hard-wiring in this knowledge into the code is
> very fragile, as even a minor one-line change to a function can change the
> status of the first upvalue. I’d much prefer a way to determine by inspection
> if _ENV is in the first upvalue or not.
Is this a correct summary of the problem you need to solve?
1. LuaState 1, to which you have full access, dumps a function,
the source of which you write, to a string.
2. LuaState 2, to which you do not have full access, somehow
gets that string, loads it and calls it.
3. You wish to write your code in such a way that the running
function can detect whether it has been called with first upvalue
equal to the table in which it looks up global variables.