[Rd] allocVector reference
simon.urbanek at r-project.org
Thu Mar 15 20:14:14 CET 2007
On Mar 15, 2007, at 8:01 AM, Andrew Piskorski wrote:
> On Wed, Mar 14, 2007 at 05:44:04PM -0000, Matthew Dowle wrote:
>> I'm trying to write a function to return an R vector which points
>> directly to a contiguous subset of another vector, without taking
>> a copy.
> Matthew, I don't know the answer to your question, but this all
> seems related to support for references in R. I've included my
> notes on R references below.
>> Since SEXPREC is a header followed by the data, rather than the
>> header plus a pointer to the data, I'm not sure what I'm trying to
>> do is possible. Is there a way of doing this? Similar in spirit
>> to how the R assignment "x=y" does not copy y until x is modified,
> Is you last statement above in fact true?
Yes. Just try
> I was under the impression that R does NOT do copy on write, that
> when you make a copy of a variable, R immediately allocates memory
> and makes a deep copy of the value.
> But you're using old deprecated "=" for assignment,
"old deprecated"? It was introduced in 1.4.0 and it is the most
recently introduced assignment operator in R. I think that you are
mistaking it for "_" which is no assignment operator anymore but used
> which is weird, so maybe you mean when you pass named arguments to
> a function? Function args are evaluated lazily, and I think that
> is used (I don't know how exactly) to give copy on write behavior -
> but only for function arguments.
More information about the R-devel