[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: metamethod __lt oddity?
- From: "Peter Hill" <corwin@...>
- Date: Sun, 19 Jan 2003 13:58:22 +0800
Peter Hill:
> 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 "[ ]".
RLake@oxfam.org.uk:
> 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.
Peter Hill:
> 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?
RLake@oxfam.org.uk:
> 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
> why.
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.
*cheers*
Peter Hill.