lua-users home
lua-l archive

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




2009/11/9 Duncan Cross <duncan.cross@gmail.com>
On Mon, Nov 9, 2009 at 7:22 PM, liam mail <liam.list@googlemail.com> wrote:
> I have come across something that I am unsure if it is expected behaviour or
> a bug and would like some help to identify which it is.
(...)
> int equal(lua_State* s)
> {
>     Int_wrapper* i1 = static_cast<Int_wrapper *>( lua_touserdata(s, 1) );
>     Int_wrapper* i2 = static_cast<Int_wrapper *>( lua_touserdata(s, 2) );
>     lua_pushinteger(s, i1->i == i2->i ? 1 : 0 );
>     return 1;
> }

I believe that the __eq metamethod (as well as the other comparison
metamethods) must return a boolean in order to work properly, so that
may be your problem.

-Duncan
Duncan even if that is the case it would not effect the fact that the method is never called. I should also say it is not just the equality operator that displays this behaviour.