by powersnail · 4y ago · 0 comments
This is on par with the "Generics in Go"^1 hack. Is there a list of this kind of funny language hack somewhere?
[1]: https://www.reddit.com/r/rust/comments/5penft/parallelizing_...
What about string + string?
I think the real rule is "it should be intuitive rather than confusing". :-)
Huh? Why?
More simply, "addition" is generally defined as a commutative operation, which this isn't. When people want a non-commutative operation, they call it "multiplication".
For a more superficial but tangible reason, if you just consider the notation, AB is the concatenation of A and B, which is the notation for a product in math. (Recall putting "A" "B" next to each other in Python literally means concatenation, and it's a product in math.)
user_name + ": " + attr1 + "| " + attr2 + "\n"
is more difficult to parse by eyeball for me then
concat(user_name, ": ", attr1, "| ", attr2, "\n")