[Rd] surprising behaviour of names<-

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Thu Mar 12 15:51:11 CET 2009


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



More information about the R-devel mailing list