From Waclaw.Marcin.Kusnierczyk at idi.ntnu.no  Thu Mar 12 15:51:11 2009
From: Waclaw.Marcin.Kusnierczyk at idi.ntnu.no (Wacek Kusnierczyk)
Date: Thu, 12 Mar 2009 15:51:11 +0100
Subject: [Rd] surprising behaviour of names<-
In-Reply-To: <49B91A7E.50107@idi.ntnu.no>
References: <49B67CB1.8060005@idi.ntnu.no>	<49B682F9.8050307@biostat.ku.dk>	<49B6E6D9.7010809@idi.ntnu.no>	<96A4BB14-D6EA-44B1-B524-6DB139F3A7F8@r-project.org>	<8CCAAAD3-919F-462F-A616-F4FDDB46D975@r-project.org>	<49B81186.4070107@idi.ntnu.no>	<20090312154008.56706f38@berwin-nus1>	<49B8D060.8090206@idi.ntnu.no>	<20090312173231.7a2929df@berwin-nus1>	<49B8DB8F.5030704@idi.ntnu.no>	<20090312213508.719afa73@berwin5>
	<49B91A7E.50107@idi.ntnu.no>
Message-ID: <49B9215F.5030201@idi.ntnu.no>

Wacek Kusnierczyk wrote:
> Berwin A Turlach wrote:
>   
>
>> This is similar to the discussion what value i should have in the
>> following C snippet:
>> 	i = 0;
>>  	i += i++;
>>   
>>     
>
>
> in fact, your example is useless because the result here is clearly
> specified by the semantics (as far as i know -- prove me wrong).  you
> lookup i (0) and i (0) (the order does not matter here), add these
> values (0), assign to i (0), and increase i (1). 
>   

i'm happy to prove myself wrong.  the c programming language, 2nd ed. by
ritchie and kernigan, has the following discussion:

"
One unhappy situation is typified by the statement

    a[i] = i++;

The question is whether the subscript is the old value of i or the new.
Compilers can interpret
this in different ways, and generate different answers depending on
their interpretation. The
standard intentionally leaves most such matters unspecified.
"

vQ



[Rd] surprising behaviour of names<-
Wacek Kusnierczyk