Overloading relational operators separately; thoughts?
Russel Winder via Digitalmars-d
digitalmars-d at puremagic.com
Sat Oct 1 10:53:44 PDT 2016
On Sat, 2016-10-01 at 14:55 +0000, Chris Wright via Digitalmars-d
wrote:
> Groovy doesn't allow you to overload comparison operators
> individually,
> and probably most JVM languages likewise. This is to retain
> compatibility
> with Java, which has `.compareTo()` instead of `isLessThan()` etc.
Yes it does. http://groovy-lang.org/operators.html
There is *also* compareTo.
> Ruby allows you to override individual comparison operators, with a
> special operator `<=>` for combined comparisons. Nim lets you
> overload
> arbitrary operators and create your own; some old discussions
> suggest
> that the Comparable type is based on `<` alone.
Groovy also supports the spaceship operator.
--
Russel.
=============================================================================
Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder at ekiga.net
41 Buckmaster Road m: +44 7770 465 077 xmpp: russel at winder.org.uk
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20161001/79ac5ec2/attachment.sig>
More information about the Digitalmars-d
mailing list