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

Vilya Harvey vilya.harvey at gmail.com
Tue Mar 10 17:19:53 PDT 2009


Accidentally hit reply instead of reply-all when responding to Neal. Here's the response.

---------- Forwarded message ---------- From: Vilya Harvey <vilya.harvey at gmail.com> Date: 2009/3/11 Subject: Re: Draft proposal: allow the use of relational operators on Comparable classes To: Neal Gafter <neal at gafter.com>

Hi Neal & thanks for the feedback.

I mentioned that in the proposal as one of the problem areas & suggested giving precedence to the unboxing operation as a solution (i.e. if a type can be unboxed, unbox it and do the comparison; otherwise, call compareTo). Does that create further problems that I'm missing? I guess it would make the desugaring a bit more complex than I'd written in the proposal, for one thing.

Vil.

2009/3/10 Neal Gafter <neal at gafter.com>

This proposal is incompatible with the existing behavior of the

comparison operators on the boxed value classes, particularly for Float and Double.

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