lua-users home
lua-l archive

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


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 share upvalues.
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:
Hi,

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.

Any ideas?

Thanks!




--

___________________________________________
Best regards,
Sergey Rozhenko                 mailto:sergroj@mail.ru