Draft proposal: allow the use of relational operators on Comparable classes (original) (raw)

Neal Gafter neal at gafter.com
Wed Mar 11 14:11:03 PDT 2009


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. Because enum types are instance-controlled by the language, you are guaranteed that == and != have a meaning that is consistent with the relational operators. Then, we could consider generalizing the mechanism to other types as a separate decision in Java 7 or 8 (or not).

Regards, Neal

On Tue, Mar 10, 2009 at 9:09 AM, Vilya Harvey <vilya.harvey at gmail.com>wrote:

I've attached a draft of a proposal to allow classes which implement the Comparable interface to be used as operands for the relational operators. So for example if you had two Strings, a and b, you would be able to write

if (a < b) { ... } instead of if (a.compareTo(b) < 0) { ... } and you could do the same with your own classes as well. Thanks in advance for any feedback, Vil.



More information about the coin-dev mailing list