static int val;
lua_pushcclosurer(L, myfunc2, 1);
lua_pushcclosurer(L, myfunc1, 1);
If its lua values you wish to share (rather than C) create the value
as a table entry and use the table for the upvalue.
On 8/14/06, firstname.lastname@example.org <email@example.com> wrote:
> Hi Lua Experts,
> Lua closures can share their private state with each other by
> their "outer local" variables. In the following code snippet "local
> cnt" is accessible by both cnt_step() and cnt_get() and no other
> function in the world could touch it.
> function cnt_init()
> local cnt= 0
> function cnt_step() cnt= cnt + 1 end
> function cnt_get() return cnt; end
> I would like to achieve the same effect using C-closures. But I
> figure out how?
> Roberto's book "Programming in Lua, 2-nd edition" that I recently
> bought shows how a C-closure stores its individual state in an
> (lua_pushcclosure). But here I need two functions to have an
> the same upvalue.
> Any help is greatly appreciated.
> Thanks and Best Regards,