It’s a shame that he lost this battle. Operator overloading really does make it a lot nicer to design certain kinds of libraries.
It’s a shame that he lost this battle. Operator overloading really does make it a lot nicer to design certain kinds of libraries.
https://en.wikipedia.org/wiki/Project_Valhalla_(Java_languag...
https://openjdk.org/projects/valhalla/
I have said in the past, and will say now, that I think it would be a good thing for the Java programming language to add generic types and to let the user define overloaded operators.
He did get the generic types though, I think that was well over a decade ago now
This was in Java 5, in 2004. So two decades!
There’s a Java compiler plugin[1] that muscles in operator overloading pretty comprehensively, and works with all LTS JDKs.
1. https://github.com/manifold-systems/manifold/tree/master/man...
a + b
suffer more from this than plus(a,b)
? In both cases, libraries will only clash if both define a function with the same name taking an A and a B. The only difference is that it is called + in the former case, and plus in the latter.The following is pretty standard:
foo::plus(a, b) // or foo.plus(a, b)
bar::plus(a, b) // or bar.plus(a, b)
Whereas this is more awkward: a foo::+ b // or a foo.+ b
a bar::+ b // or a bar.+ b