[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: metamethod __lt oddity?
- From: "Peter Hill" <corwin@...>
- Date: Sun, 19 Jan 2003 13:58:22 +0800
> Useful, but I don't think we need an extra symbol. We could have "raweq"
> to test for raw equality, just like we have "rawget/rawset" for the
> indexing symbol "[ ]".
> This has been hashed out at length on the mailing list, so I won't go over
> old ground again.
Fair enough. Sounds like we need a mailing list FAQ.
> They keep two, which could then be made contradictory. Why? If the authors
> didn't want to supply the whole set (lt, le, gt, ge) why didn't they just
> reduce it to a single operator?
> If a < b is not the same as b > a, then you probably shouldn't be using
> things that look like comparison operators.
> Having both < and <= is useful in cases where one or the other is easier
> to implement. In partial ordering, <= is often easier to implement. That's
If we had only one ordering metamethod, eg "a<b", and our situation was such
that it was easier to implement "c<=d" then we could simply assign "__lt =
function(a,b) return not easy_le(b,a) end"
Also, that doesn't explain why there is an asymmetry where "a <= b" will
default to "not (b<a)" if "__le" does not exist, while "a<b" does not
default to "not (b<=a)" if "__lt" does not exist.