On 30.10.2016 18:43, Russel Winder wrote:
On Sun, 2016-10-30 at 10:06 +0100, Cédric Champeau wrote:
I'm -1 on adding custom operators. We always said we wouldn't fall
into the
same trap as C++ or Scala, but instead allow overriding existing
operators.
I like custom operators as in Algol-68 and Scala. It is just that some
Scala codes take things too far, showing a lack of self-restraint, and
inability to read. This however is not a reason to abandon the idea.
Consider that C++ and Python both restrict the overloading to the
operators known to the compiler. Note that Java removed this because it
was too hard for programmers to understand. Note that Groovy has
reintroduced this because programmers wanted it. Also that Scala and
Kotlin have followed suit and/or gone further.
There is a balance between condescension and authoritarianism (which a
number of programming languages are now following) and leaving it to
the programmer to do the right thing at the risk of them not, but it is
their problem. I am not a fan of condescending authoritarianism.
I think the biggest mistake is to allow the general overloading of "=".
Be it with some automated type coercion or another user over-writable
mechanism. We have to some extend for assignment to Boolean with
asBoolean, but not in general and not specialized for "=", especially
not for arbitrary types. I think it was a big mistake for Scala to
introduce something like this. It makes DSLs nicer, yes, but it makes it
incredibly difficult for the programmer to follow the program flow.
So if we add custom operators, we should ensure they fit in the general
program flow
bye Jochen