lua-users home
lua-l archive

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


> >     lua_pushcfunction(L, cfunc);
> >     lua_pushcfunction(L, cfunc);
> >     int ret = lua_rawequal(L, -1, -2);
> >     // ret == 0
> 
> On the stack there are two *different* closures of the same C function. Hence,
> two different Lua values.

You can compare the C functions using lua_tocfunction:

   /* assuming both are actually C functions */
   if (lua_tocfunction(L, -1) == lua_tocfunction(L, -2)) ...

-- Roberto