Op Sa. 22 Des. 2018 om 05:48 het Jonathan Goble <firstname.lastname@example.org> geskryf:
> Can a function (Lua or C) in Lua 5.2+ gain access to its caller's _ENV,
Only as an upvalue, and even then, only if your function refers to it,
e.g. via a global name.
> and if so, can it modify that table
> and/or replace that table with a new one?
Even with debug.setupvalue?
> What I'm looking for is an approach that allows all three (access, modify, and replace) without writing "_ENV" (or the name of any variable that refers to _ENV) anywhere in the statement that calls the function.
> Any thoughts on how to do this? Or is it not possible?
Do you grant me the debug library?
To quote the sentence immediately following one you just quoted: "I'm open to any solution, including complicated debug library hacks and/or the C API, as long as it would work consistently."