[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Is there anyway to make a new Lua closure sharing the same code with old one but with different env table?
- From: Jerome Vuarand <jerome.vuarand@...>
- Date: Mon, 21 Jun 2010 17:31:41 +0200
2010/6/21 Kristofer Karlsson <email@example.com>:
> function functionfactory()
> local upvalue1, upvalue2
> return function()
> return upvalue1 + upvalue2
> local clone1 = setfenv(functionfactory(), env1)
> local clone2 = setfenv(functionfactory(), env2)
> clone1 and clone2 now shares prototype and upvalues, but have different
> Is this what you meant?
I think that's what he meant. But given clone1 as input, can you
generate clone2 ? AFAICT no.