[Rd] "+" for character method...

Thomas Lumley tlumley at u.washington.edu
Mon Aug 28 00:21:39 CEST 2006

On Sat, 26 Aug 2006, John Chambers wrote:

> Well, two comments, in two non-compatible directions.
> 1.  I have to say that I find the idea of using "+" to paste character
> strings together aesthetically ugly.

Hear, hear!

In a language where you can define new binary operators easily making the 
same operator do addition and concatenation really doesn't seem a good 
idea. It is done in some other languages, but so is using the same 
operator for printing and multiplying by powers of two.

Lack of commutativity is obvious, but lack of associativity seems much 
more dangerous. Suppose x, y, and z are a mixture of strings and numbers. 
Hands up everyone who knows (without cheating) whether x+y+z would be 
interpreted the same way in R (with the current parser) as in Java or 
Delphi or Python (and are these all the same?).  Which of
    "two + two = " + 2 + 2
    2 + 2 + " = two + two"
would be correct?


Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle

More information about the R-devel mailing list