Draft proposal: allow the use of relational operators on Comparable classes

Vilya Harvey vilya.harvey at gmail.com
Thu Mar 12 10:02:31 PDT 2009

2009/3/12 Kevin Bourrillion <kevinb at google.com>

> On Wed, Mar 11, 2009 at 2:11 PM, Neal Gafter <neal at gafter.com> wrote:
> Vilya-
>> I suspect that if you narrowed the scope of this proposal to just enum
>> types, it would have a much better chance of getting accepted for project
>> Coin.
> To the general proposal, I believe the problem of conflicting meanings of
> <=, >= and == make it a non-starter.

I tried implementing the change & it was remarkably simple - without having
looked at any of the openjdk code before, it took me just one evening; hats
off to the compiler designers! However even the first bit of example code I
wrote to test it with looked a bit strange:

String a, b;
if (a < b)
    System.out.println("a < b");
else if (a > b)
    System.out.println("a > b");
else if (a == b)
    System.out.println("a == b");
    System.out.println("a.compareTo(b) == 0")';

It seems really odd that the else clause is actually reachable, but of
course it is. I suspect that would catch a lot of people out.

So given that experience and having read everyone's comments, I've come to
the conclusion that the proposal would only make sense if it was part of a
larger plan that included changing the meaning of == and !=. That would be
such a breaking change that I doubt it will ever happen, much less in the
jdk7 time frame, so I'm withdrawing the proposal.

Thanks a lot to all of you who provided me with feedback!


More information about the coin-dev mailing list