News for hackers. Stuff that matters.
Re:Examples of Incorrect Abstractions in Other Languages by enriquto on Wednesday May 20, 2020 @04:09AM (#23244483)
The problem here is that using "sum" or "+" for string concatenation is an idiotic choice of words in the base language (because concatenation is not commutative).
Re:Examples of Incorrect Abstractions in Other Languages by iainmerrick on Wednesday May 20, 2020 @07:18AM (#23245546)
Right! Isn’t concatenation “++” rather than “+” in Haskell for exactly that reason?

So if “sum” is a shortcut for “fold with +”, summing a list of strings wouldn’t make sense.

Python still isn’t as regular as it could be, of course, as it does use “+” for concatenating strings.

I think this can all be justified for ergonomic reasons -- using the simple “+” for strong concatenation is convenient, but “sum” is discouraged for strings because it’s slow.

It would be interesting to see a parallel-universe Python that didn’t allow “+” on strings. I wonder if it would have caught on.

Re:Examples of Incorrect Abstractions in Other Languages by enriquto on Wednesday May 20, 2020 @09:36AM (#23246628)
Literally any symbol other than "+" would work better for string concatenation. For example, the product, the comma, a dot, a space (but this might require other changes in the language), or heck, even the minus sign!