Am 30.03.2011 22:34, schrieb Dmitry Olshansky:
On 30.03.2011 2:14, so wrote:
On Tue, 29 Mar 2011 22:56:10 +0300, dsimcha <dsim...@yahoo.com> wrote:

Occasionally i encounter this argument that operator overloading is
bad thing when it is abused.
I don't overload operators offensively myself, i use dot(vec, vec)
cross(vec, vec) for example because there is not a suitable operator
and these names suits much better.

On the other hand i am not against languages being flexible, quite
contrary i don't call it a language if it is not.
OO is an impressive tool and we need tools like this for better
libraries. You can't change a language for a long time but you can
update a library in very short period of time.

vec add(a, b) { return a.x - b.x }
vec operator+(a, b) { return a.x - b.x }

Is there a difference?

The second one plays havoc with parsing :) It's not that it's such a big
problem but ..
BTW when does + denotes a difference?


(Probably) Never..
I think his point is that using a bad operator-overload (overload the "+" operator for subtracting) isn't worse than using a bad function name (like "add" when you're really subtracting).

Cheers,
- Daniel

Reply via email to