From murdoch.duncan at gmail.com  Sun Jan 23 18:38:47 2011
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Sun, 23 Jan 2011 12:38:47 -0500
Subject: [Rd] "+" operator on characters revisited
In-Reply-To: <E410A01D-653A-434F-B971-9EAC08324AC8@gmail.com>
References: <878vycd7ld.fsf@gmail.com>
	<E410A01D-653A-434F-B971-9EAC08324AC8@gmail.com>
Message-ID: <4D3C67A7.4040101@gmail.com>

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



[Rd] "+" operator on characters revisited
Duncan Murdoch