PROPOSAL: Equivalence operators (formerly titled

Vilya Harvey vilya.harvey at
Sat May 9 04:14:50 PDT 2009


2009/5/9 Mark Thornton <mthornton at>:
> Why can't we overload >= and <= instead in the same way as < and > (i.e.
> only apply to Comparable types which are NOT convertable to primitives).

This is exactly what I proposed a few months ago. I ended up
withdrawing the proposal because it gives you a strange-looking
asymmetry with == and !=. You can't == or != to be based on Comparable
because it would break way too much code, but without changing them,
you end up with statements like this being valid:

if (a < b)
else if (a > b)
else if (a == b)

There's also the possibility of the operators causing a
ClassCastException to watch out for, as well as a

I still like the idea myself, but it certainly has the potential to be

Hope that helps,

More information about the coin-dev mailing list