From simon.urbanek at r-project.org  Sat Nov 10 04:01:49 2012
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Fri, 9 Nov 2012 22:01:49 -0500
Subject: [Rd] built-in NAMED(obj) from within R
In-Reply-To: <CABdHhvEp_Pfn72GP5q-0RdxzW--MKL_1z-rHNCEFbvoC8ws44Q@mail.gmail.com>
References: <509C7CD1.7080105@gmail.com>
	<loom.20121109T125440-643@post.gmane.org>
	<CABdHhvFMGGU_jFSeYq8i4C1vH9=poJ21PJv1eO=S0wFm76e=uQ@mail.gmail.com>
	<BA1B8718-4D98-4C04-8D40-E409D1A774E0@r-project.org>
	<CABdHhvEp_Pfn72GP5q-0RdxzW--MKL_1z-rHNCEFbvoC8ws44Q@mail.gmail.com>
Message-ID: <CA9FBAA4-15BF-400F-911D-5B58DB26085F@r-project.org>

On Nov 9, 2012, at 9:46 PM, Hadley Wickham wrote:

> On Friday, November 9, 2012, Simon Urbanek wrote:
> 
> On Nov 9, 2012, at 8:00 AM, Hadley Wickham wrote:
> 
> >>> The goal is to ascertain whether a copy of an object has been made.
> >>
> >> Then :
> >>
> >>    ?tracemem
> >>
> >> One demonstration of using both together is here :
> >>
> >>    http://stackoverflow.com/a/10312843/403310
> >
> > Note that tracemem detects duplications (in a technical R sense), not
> > copies - i.e.
> >
> > x <- 1:10
> > tracemem(x)
> > x[11] <- 11L
> >
> > although all the individual elements are copied,
> 
> No elements are copied - this is a subassignment and it is done in place hence there is neither duplication nor copying - simply the value of the 11th element is changed.
> 
>  But there was no 11th element - it was only 10 long. 
> 

Ah, I see what you mean - the misleading part is rather that x is now a new object that is no longer traced - this is not about duplication or copying.

Cheers,
Simon



[Rd] built-in NAMED(obj) from within R
Simon Urbanek