[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: GrayFace <sergroj@...>
- Date: Tue, 22 Jun 2010 06:53:02 +0700
Here's the dumb solution I can think of:
dump function and load it, then join upvalues with the original
function. They won't have the same proto, but will do the same thing and
I've made a patch for Lua 5.1 for upvaluejoin and can upload it somewhere.
With use of internal API I think it can be done more elegant and exactly
as you need, but that's just my guess.
On 21.06.2010 10:03, Chaos Wang wrote:
I wonder if there is any way to clone a Lua closure, where the clones
share the same Proto and upvalues but have different environment tables?
I tried lua_pushvalue(), but it only make a direct reference for
GC-able object (which includes closures), so there can't be different
environment tables coexisted.
Sergey Rozhenko mailto:firstname.lastname@example.org