Arc Forumnew | comments | leaders | submitlogin
2 points by rocketnia 4524 days ago | link | parent

"Punning functions for different meanings is fine if done tastefully. In particular, + for concatenation is fine."

The reason I'm okay with using + for concatenation is because I intuitively accept addition as a special case of concatenation. Concatenation is all + does.

However, I'm not as sure about this as I used to be. I can list a few reasons for separating addition from concatenation, and indeed for separating all kinds of seemingly polymorphic operators:

- Just because one operator gives us three context-appropriate kinds of concatenation doesn't mean we can define another operator that gives us the context-appropriate identity element (() or "" or 0).

- Addition tends to promise more algebraic properties than concatenation does (e.g. commutativity), so it may be easier to trust the behavior of an addition operator if it doesn't have concatenation weighing it down.

- Among numbers, there are multiple associative operators with identity, including addition, multiplication, and max (on the extended real number line), and I'm not sure any of these stands out as a natural choice for "concatenation."

---

"The infix version [...] is far inferior[...]"

I don't see that much inferiority. Maybe I've been working in JavaScript too long. Maybe I'm just making excuses to disagree with you. :-p

---

"Given that I want to resist the temptation to use infix + on lists and strings, I'm inclined to continue supporting join, and only use + for the easiest case"

Well, if I saw code that used 'join, I would be tempted to turn it into +, especially when it saves on indentation. YMMV.