[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: comparing C functions using lua_rawequal
- From: roberto@... (Roberto Ierusalimschy)
- Date: Fri, 13 Jul 2007 09:33:44 -0300
> > 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