lua-users home
lua-l archive

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


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.

That's probably true.


>In partial ordering, <= is often easier to implement. That's why.

Hmm, I think that the cause you state is right but the argument (for having
both "lt" and "le" definable together) is actually wrong.

It's not because sometimes "<=" is simpler to implement but rather that, in
a partial ordering, the default rule "a<=b" equals "not (b<a)" is just NOT
true (since in a partial order one can have elements which are neither
greater than, less than, nor equal to each other).

The correct definition would be:
    a<b   :=:   (a<=b) and not (a==b)

where we define "==" as:
    (a == b)   :=:   (a<=b) and (b<=a)

Lua doesn't define the default for "<" that way so we would have to overide
it manually to get a correct result for a partial order.

So, I guess I've answered my own original question as to why both "lt" and
"le" exist :-O, though I'm not sure I'm happy with the lack of neatness and
fudginess in the result :-(.

*cheers*
Peter Hill.