lua-users home
lua-l archive

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


On 07/26/2013 03:40 PM, Philipp Janda wrote:
Am 26.07.2013 17:17 schröbte Andrew Starks:

Within my own Lua code, I often want to turn an object into a plain
number. The meta-methods can effectively do most of what I want, but
not when I'm dealing with relational operators when one side of is an
actual number.

Finally, __tonumber just feels... missing. I even had to triple check
that it wasn't in 5.2, lest I embarrass myself. :)

But Lua 5.2 *does* have support for mixed arguments in relational operations :-p

Unless you want to test for equality. And at some point down the road you will have to test for it. I would actually never define the comparison metamethods for mixed types because once you test for equality it will always be confusing.

--
Thomas