Re: Equality...
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Equality...
- From: Roberto Ierusalimschy <roberto@...>
- Date: 1999年7月29日 11:26:32 -0300
> Is there a way to tell if two lua_Objects are equal from within C? [...]
No :-( We will consider a function for that for the next version.
> The only technique I can come up with involves lua_dostring, but that's
> not particularly elegant.
You can do a little better than the obvious solution, using dostring only
once to create the function you need:
/* untested code */
int eq; /* global? static? */
...
/* initialize eq */
lua_dostring("return function (a,b) return a==b end")
lua_pushobject(lua_getresult(1));
eq = lua_ref(1);
int is_equal (lua_Object a, lua_Object b) {
lua_pushobject(a);
lua_pushobject(b);
lua_callfunction(lua_getref(eq));
return !lua_isnil(lua_getresult(1));
}
-- Roberto