Hello all,
I’m wondering if there’s any way in Lua to assign a local variable in the caller’s scope from within a function.
To clarify, I’d like to write a helper function like this:
import("foo", "x")
which would behave as if the caller had written:
local x = require("foo").x
and I’m curious if there’s any metaprogramming trick, debug API feature, or other mechanism that would make this possible. Has anyone tried this before? Is it fundamentally impossible, or just generally discouraged?
Thanks in advance for any insights.
Best regards,
Federico Ferri