[Rd] string concatenation operator (revisited)
r@d|ord @end|ng |rom c@@toronto@edu
Mon Dec 6 07:14:02 CET 2021
> The TL;DR version is base R support for a `+.character` method. This
> would essentially provide a shortcut to `paste0`...
In pqR (see pqR-project.org), I have implemented ! and !! as binary
string concatenation operators, equivalent to paste0 and paste,
> "hello" ! "world"
> "hello" !! "world"
 "hello world"
> "hello" !! 1:4
 "hello 1" "hello 2" "hello 3" "hello 4"
This seems preferable to overloading the + operator, which would lead
to people reading code wondering whether a+b is doing an addition or a
string concatenation. There are very few circumstances in which one
would want to write code where a+b might be either of these. So it's
better to make clear what is going on by having a different operator
for string concatenation.
Plus ! and !! semm natural for representing paste0 and paste, whereas
using ++ for paste (with + for paste0) would look rather strange.
More information about the R-devel