lua-users home
lua-l archive

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


2010/6/21 Kristofer Karlsson <kristofer.karlsson@gmail.com>:
> 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
> Is this what you meant?

I think that's what he meant. But given clone1 as input, can you
generate clone2 ? AFAICT no.