[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: using setfenv recursively
- From: "Matthew Armstrong" <turkeypotpie@...>
- Date: Sun, 4 Nov 2007 21:33:20 -0800
Is it possible to use setfenv recursively? When I call setfenv, it attaches to the function, but it seems like it should more naturally attach to the function's call.
I have a little wrapper function to protect my environment:
function protectedEnv(func)
local env = {}
setmetatable(env, { __index = _G })
setfenv(func, env)
return func
end
...
myFunc = protectedEnv(
function()
-- If I call myFunc inside here, my environments start colliding.
end)
...
myFunc()