[Rd] "+" operator on characters revisited

Duncan Murdoch murdoch.duncan at gmail.com
Sun Jan 23 18:38:47 CET 2011


On 23/01/2011 11:50 AM, peter dalgaard wrote:
>
> On Jan 22, 2011, at 21:08 , Vitalie S. wrote:
>
>> The only definite argument occurred in the thread against "+" operator
>> was the lack of commutativity (as if one have to prove algebraic
>> theorems in R).
>
> I think the real killer was associativity, combined with coercion rules:
>
> Is "x"+1+2 supposed to be equal to "x12" or "x3"?
>

As I pointed out at the time, we don't even have associativity for 
integer addition.  For example in

-1L + .Machine$integer.max + 1L

the two possibilities

(-1L + .Machine$integer.max) + 1L

and

-1L + (.Machine$integer.max + 1L)

give different results.  When I try it now without parentheses, I get 
the same answer as the first one, but I don't believe we guarantee that 
that will always be so.

Duncan Murdoch



More information about the R-devel mailing list