3 ms·
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 commutativ
by enriquto 6y ago
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).
- iainmerrick 6y agoRight! 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.
- enriquto 6y agoLiterally 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!