[Rd] string concatenation operator (revisited)

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Sun Dec 5 17:50:23 CET 2021

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 using 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

More information about the R-devel mailing list