Operator overloading

Operator overloading is syntactic sugar, and is used because it allows programming using notation nearer to the target domain[1] and allows user-defined types a similar level of syntactic support as types built into a language.

Another, more subtle, issue with operators is that certain rules from mathematics can be wrongly expected or unintentionally assumed.

For example, the commutativity of + (i.e. that a + b == b + a) does not always apply; an example of this occurs when the operands are strings, since + is commonly overloaded to perform a concatenation of strings (i.e. "bird" + "song" yields "birdsong", while "song" + "bird" yields "songbird").

Subsequent revisions of the language (in 1995 and 2005) maintain the restriction to overloading of extant operators.

[44] Java language designers at Sun Microsystems chose to omit overloading.

[45][46][47] Python allows operator overloading through the implementation of methods with special names.

Ruby allows operator overloading as syntactic sugar for simple method calls.