lua-users home
lua-l archive

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

> 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")
  eq = lua_ref(1);

int is_equal (lua_Object a, lua_Object b) {
  return !lua_isnil(lua_getresult(1));

-- Roberto