Overloading relational operators separately; thoughts?
Chris Wright via Digitalmars-d
digitalmars-d at puremagic.com
Sat Oct 1 07:55:49 PDT 2016
On Fri, 30 Sep 2016 23:31:19 +0000, Sai wrote:
> Genuine question: In the post Java languages, how many languages allowed
> unrestricted operator overloading and did that cause any similar mess?
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.
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.
More information about the Digitalmars-d
mailing list