News for hackers. Stuff that matters.
Re:Go at SoundCloud by azylman on Tuesday July 24, 2012 @02:24PM (#4287161)
add(foo, bar) isn't any clearer than foo + bar, but usually an overloaded operator doesn't correspond to "add".

For example, in Javascript: "Hello" + " " + "World!". What the operator there is doing is concatenating the strings, so if you had a method to do it you wouldn't call it add - you'd call it concat.

Re:Go at SoundCloud by numeromancer on Tuesday July 24, 2012 @04:18PM (#4287744)
But then you lose the information that both ((usually modular) arithmetic, and strings with concatenation, et al.) are monoids, and have a similar structure, and creating generic functions which might use that symmetry becomes more difficult.
Re:Go at SoundCloud by rat87 on Tuesday July 24, 2012 @10:04PM (#4289031)
In python you can overload + and a lot of other numeric operators by implementing certain methods __add__ for +, see others here: http://docs.python.org/reference/datamodel.html#emulating-nu...

In ruby you can implement certain numerical methods including +

In smalltalk + is a binary method, you can give your methods all sort of symbol names. Same with Scala I think.

Re:Go at SoundCloud by gurkendoktor on Thursday July 26, 2012 @01:55PM (#4297540)
> For example, in Javascript: "Hello" + " " + "World!". What the operator there is doing is concatenating the strings

Hmm, are we talking about (user defined) operator overloading as a language feature, or about overloaded operators? For example, I hate that 1/2 and 1.0/2 are different things in most languages, but I haven't heard anyone call this operator overloading in the context of C.