From matloff at cs.ucdavis.edu  Sun Apr  4 00:34:35 2010
From: matloff at cs.ucdavis.edu (Norm Matloff)
Date: Sat, 3 Apr 2010 15:34:35 -0700
Subject: [Rd] full copy on assignment?
Message-ID: <20100403223435.GA27306@laura>


Here's a basic question that doesn't seem to be completely answered in
the docs, and which unfortunately I've not had time to figure out by
wading through the R source code:

In a vector (or array) element assignment such as 

   z[3] <- 8 

is there in actuality a full rewriting of the entire vector pointed to
by z, as implied by

   z <- "[<-"(z,3,value=8)

Assume that an element of z has already being changed previously, so
that copy-on-change issues don't apply, with z being reassigned back to
the same memory address.

I seem to recall reading somewhere that recent R versions make some
attempt to avoid rewriting the entire vector, and my timing experiments
seem to suggest that it's true.  

So, is a full rewrite avoided?  And where in the source code is this
done?

Thanks.

Norm Matloff



[Rd] full copy on assignment?
Norm Matloff