Some programmers out there seem to think operator overloading is unnecessary (example: here
). But only because they never needed a feature like that in their life, it doesn't mean that it is not useful. Java or Actionscript for example don't support operator overloading. Some code in the Coppercube engine
for example looks like this:
finalPos = p1.multiplyWithScal(g1);finalPos.addToThis(p2.multiplyWithScal(g2));finalPos.addToThis(t1.multiplyWithScal(g3));finalPos.addToThis(t2.multiplyWithScal(g4));
In C++, the same code would simply be something like this:
finalPos = (p1*g1 + p2*g2 + t1*g3 + t2*g4);
The code is only working with 3D vectors and scalars, but there are also similar parts for matrices, 2d vectors, lines, quaternions and others in there.
Code like this is distributed trough the whole code base, making these parts totally unreadable. I'm used to write a comment above such lines, showing how the code would look like if the language would support operator overloading, which explains what the code does. And makes it obvious that operator overloading would be quite useful in that language.
So if you are designing a new programming language, think about adding operator overloading for us poor programmers having to work with all this math stuff. :)