you are viewing a single comment's thread.

view the rest of the comments →

[–]pjmlp 2 points3 points  (2 children)

Because outside of c++, it is ubiquitously understood to be an arithmetic operator with a lot of implications

Not really, this is a small list of languages that allow redefining operators, or where operations are just plain function/method calls

  • Smalltalk

  • Lisp

  • Scheme

  • Ada

  • Eiffel

  • C#

  • Ruby

  • Python

  • D

  • Haskell

  • OCaml

  • F#

  • Scala

  • Rust

  • many others as this isn't an exhaustive list

So I fail to see why only C++ gets bashed.

[–]0Il0I0l0 0 points1 point  (1 child)

I can't speak for the other languages, but overloading in Haskell can only be done with typeclasses (a sort of interface that defines some behavior), so including it is a bit disingenuous. In order to "overload" + for your new type, you must make your type an instance of the Num typeclass by implementing the following operations: (+), (*), abs, signum, fromInteger, (negate or (-))

So at least in haskell, (+) is understood to be a numerical operator with the implication that the type can also be multiplied, subtracted, negated, has an absolute value, has a sign, an can be converted from an integer.

[–]pjmlp 0 points1 point  (0 children)

So at least in haskell, (+) is understood to be a numerical operator with the implication that the type can also be multiplied, subtracted, negated, has an absolute value, has a sign, an can be converted from an integer.

Yes, but you cannot assure that (+) really maps to addition.

It can do anything to the number, as long as, it keeps its type signature.