Proposal: Sameness operators

Mark Thornton mthornton at
Thu Apr 2 10:42:21 PDT 2009

Reinier Zwitserloot wrote:
> The argument that .compareTo should not be used because it isn't 
> entirely congruent with either the meaning of .equals() or the 
> meanings of all the comparison operators (from == to <) on the 
> primitives, just doesn't hold water, for this simple reason:
I merely meant that if you want to have a set of comparison operators 
with some of them based on compareTo, then they all must be based on 
compareTo --- you can't use equals (or ==) for the equality comparisons. 
Therefore you have three sets of operations

==, System.identityHashCode(), plus for some types <, <=, >, >=

Object.equals(), Object.hashCode()


All these need to remain clearly distinct because their existing 
behaviour is not always compatible.

Mark Thornton

More information about the coin-dev mailing list