lua-users home
lua-l archive

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


On Sat, Dec 22, 2018 at 8:36 AM Dirk Laurie <dirk.laurie@gmail.com> wrote:
Does the following formulation of your question accurately convey what you ask?
~~~
function global_function()
-- ...
end

local function upvalue_function()
-- ...
end

function f1(param_function)
  _ENV = {NAME='f1_env'; global_function = global_function}
  global_function()   -- Can this call change _ENV.NAME? Or even _ENV itself?
  upvalue_function()  -- Can this call change _ENV.NAME? Or even _ENV itself?
  param_function()    -- Can this call change _ENV.NAME? Or even _ENV itself?
end
~

Yes. Within any of global/upvalue/param_function, can they change f1's _ENV contents or f1's _ENV itself? Consider also the case (actually the primary case for what I'm considering) where f1 is not a normal function, but the anonymous function of a compiled chunk, such as a module being loaded by require().