lua-users home
lua-l archive

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


> The error I get is "lua: metamethods.lua:27: attempt to compare table with
> number". From the documentation it would seem that this should work, just
> as t+4 does. Or am I missing something?

Wim Couwenberg:
> Lua 5 will report this error if the operands don't have the same type.
> This behavior is different from the + operator.  I don't know the reason
> behind this.  It does look odd that such constructions (e.g. comparing
> table-based custom "types" with non-table data) don't seem possible.
>
> Does anyone know why it was implemented like this?

It seems to be as you say, yet the pseudo-code for "__lt" in the manual
doesn't show this! Something is wrong somewhere.

*cheers*
Peter Hill.