From r@d|ord @end|ng |rom c@@toronto@edu  Mon Dec  6 07:14:02 2021
From: r@d|ord @end|ng |rom c@@toronto@edu (Radford Neal)
Date: Mon, 6 Dec 2021 01:14:02 -0500
Subject: [Rd] string concatenation operator (revisited)
In-Reply-To: <mailman.52192.3.1638702001.27673.r-devel@r-project.org>
References: <mailman.52192.3.1638702001.27673.r-devel@r-project.org>
Message-ID: <20211206061402.GA3810@mail.cs.toronto.edu>

> 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,
respectively.  

For instance,

    > "hello" ! "world"
    [1] "helloworld"
    > "hello" !! "world"
    [1] "hello world"
    > "hello" !! 1:4
    [1] "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.

   Radford Neal



[Rd] string concatenation operator (revisited)
Radford Neal