lua-users home
lua-l archive

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

>From the manual: " The function getcomphandler defines how Lua chooses a metamethod for comparison operators. A metamethod only is selected when both objects being compared have the same type and the same metamethod for the selected operation." Hence userdata cannot be compared to non-userdata without modifing the Lua source.

On Mon, Nov 24, 2008 at 1:37 PM, Nikolai Kondrashov <> wrote:
Hello everybody,

Is there is a reason why I cannot compare a number with userdata? Provided
I have necessary metamethods?

The problem is we're using long-based Lua (on MIPS) and sometimes need to
deal with bigger integers, particularly 64-bit ones - only a few operations.

So I've implemented a simple Lua library in C operating on them. All
arithmetic operations work fine, but comparisons won't, giving "attempt to
compare number with userdata" message.

If there is no reason, then where should I look in Lua sources to fix that?