« Return to Thread: Overloading comparison operators

Re: Overloading comparison operators

by Jochen Theodorou :: Rate this Message:

Reply to Author | View in Thread

Jörg Staudemeyer schrieb:
> Hi
>
> are there any plans to change handling of comparison operators in a
> later version of Groovy?

there are plans to change it for 2.0, there are not yet plans on how to
exactly do that. I am thinking about removing the dependency on the
Compareable method and just go with methods that might be defined or
not, like we do with plus, minus, shift, etc.

> Currently, comparison operators only apply to classes that implement the
> Comparable interface and are mapped to the compareTo() method.
> compareTo() method must return an integer value, as dictated by the
> interface, but the result of a comparison expression is always boolean.
 >
> IMO this is not consistent with handling of other operators like + and
> << that always map to a specific method returning an arbitrary result
> value. As a result, usage of comparison operators in DSLs >

I agree. It was done in early days for speed. Now that Groovy is faster
it should be changed... but the thought of letting <,> return something
that is not boolean didn't occur to me yet... but true, for a DSL this
might be very interesting. You could leave a comment in
http://jira.codehaus.org/browse/GROOVY-2756

bye blackdrag

--
Jochen "blackdrag" Theodorou
The Groovy Project Tech Lead (http://groovy.codehaus.org)
http://blackdragsview.blogspot.com/
http://www.g2one.com/

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Overloading comparison operators