|
On 21 June 2010 08:48, Kristofer Karlsson <kristofer.karlsson@gmail.com> wrote:Actually, each of the returned functions have their own upvalues, they
> function functionfactory()
> local upvalue1, upvalue2
> return function()
> return upvalue1 + upvalue2
> end
> end
>
> local clone1 = setfenv(functionfactory(), env1)
> local clone2 = setfenv(functionfactory(), env2)
>
> clone1 and clone2 now shares prototype and upvalues, but have different
> environments
aren't shared. If you lifted "local upvalue1, upvalue2" out of
functionfactory, then they would be shared.
henk