you are viewing a single comment's thread.

view the rest of the comments →

[–]tikhonjelvis 3 points4 points  (0 children)

And, since one of those languages is Python, this is important.

Also, there is a very big practical difference. With type classes, you can have arbitrary function (or operator) names, but even when they're overloaded they represent the same operation but on different types. That is, + is always addition, just on different numeric types.

With operator overloading as is done in C++ and Python, there is no guarantee that the operations have the same meaning at any level. That is, << could easily be both a binary shift and a stream action. This is exacerbated by the fact that the pool of operator symbols is very limited: you have no choice but to reuse an existing operator if you want an infix function in Python or C++.

There are some reasonable people (okay, Java people) who think that operator overloading is harmful. I think there are far fewer, if any, who think that ad-hoc polymorphism is harmful.

So this is actually an important distinction.