Re: is setfenv useless?
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: is setfenv useless?
- From: "mr. Aleph" <mraleph@...>
- Date: 2006年3月06日 09:35:29 +0600
PA wrote:
local aFunction = function( aName )
return ( "%s! Yes, we can!" ):format( aName )
end
local aFunctionCopy = loadstring( string.dump( aFunction ) )
This trick won't help you with cfunctions. And require is a cfunction.
Why called function doesn't inherit the environment of caller?
--pseudocode
function __call(callee, caller)
if not callee.env.wasChangedBySetfenv then
local env = callee.env
callee.env = caller.env
__real_call(callee)
callee.env = env
else
__real_call(callee)
end
end