From murdoch@dunc@n @end|ng |rom gm@||@com  Sun Dec  5 17:50:23 2021
From: murdoch@dunc@n @end|ng |rom gm@||@com (Duncan Murdoch)
Date: Sun, 5 Dec 2021 11:50:23 -0500
Subject: [Rd] string concatenation operator (revisited)
In-Reply-To: <20211205152212.3b7a6806@Tarkus>
References: <MWHPR1001MB2384CD0939331AF4B4DE9C41CF6B9@MWHPR1001MB2384.namprd10.prod.outlook.com>
 <00df01d7e97f$74cc8d80$5e65a880$@verizon.net>
 <20211205152212.3b7a6806@Tarkus>
Message-ID: <a499c740-940d-7ef0-b80c-70b968983a65@gmail.com>

On 05/12/2021 7:22 a.m., Ivan Krylov wrote:
> On Sat, 4 Dec 2021 21:26:05 -0500
> Avi Gross via R-devel <r-devel at r-project.org> wrote:
> 
>> In many languages, like PERL, this results in implicated conversion
>> to make "text1" the result.
> 
> FWIW, Perl5 has a separate string concatenation operator (".") in order
> to avoid potential confusion with addition. So do Lua (".."), SQL
> ("||", only some of the dialects) and Raku ("~", former Perl6). Some of
> the potential concerns with string concatenation as an operator in R
> could be alleviated by introducing a separate operator, just like matrix
> multiplication ("%*%") is separate from elementwise multiplication
> ("*"), nowadays even in Python ("@" and "*", respectively).
> 

People seem to handle the automatic conversion of comparison operators. 
  Occasionally someone is surprised that

   123 < "5"

is TRUE, but mostly people muddle along.

One possible issue is that for some things (e.g. S3 Arith group 
generic), "+" is grouped with the other arithmetic operators, "-", "*", 
"^", "%%", "%/%", "/".  I don't think it would make sense for any of 
them to work on strings.  But there are exceptions listed for number of 
arguments among the Math group, so an exception in the Arith group 
wouldn't be the end of the world.

Duncan Murdoch



[Rd] string concatenation operator (revisited)
Duncan Murdoch