Can a function (Lua or C) in Lua 5.2+ gain access to its caller's _ENV, and if so, can it modify that table and/or replace that table with a new one? I know access and modification are trivial if you require passing the _ENV table as an argument, and replacement is trivial if you simply return a table that documentation specifies must be assigned to _ENV. I'm not interested in those simple "tricks".
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. I'm open to any solution, including complicated debug library hacks and/or the C API, as long as it would work consistently. Bonus points for a single approach that works on 5.2, 5.3, and the 5.4work git HEAD with minimal or no branching to deal with differences between versions.
Any thoughts on how to do this? Or is it not possible?