On Tue, 24 Apr 2001, David James wrote:
Hi,
In section 4.6.7 of "Writing R Extensions" (Version 1.2.1, 2001-01-15)
the C function defineVar() is described as "... the equivalent
of assign(symbol, value, envir = rho, inherits = FALSE) ..."
I interpreted the above (wrongly) as meaning that defineVar() makes
a copy of its "value" argument into the object whose name is specified
in "symbol" in the "rho" environment (that's how assign() works at the
R/S level). However, this is not exactly how defineVar() appears to work.
In particular, it appears to assign the object in the environment "rho",
but further changes in the C code to the object are reflected in the
"assigned" object in rho (i.e., no actual copy of the object is made).
I can see that the implemented behavior is quite useful, but it's not
exactly equivalent to assign(). Perhaps the documentation should be more
explicit and add a sentence to warn users that the data part of the
object is shared? (The sentence may need to be more precise, though.)
I'm happy to do so, but can someone provide the more precise sentence,
please. When exactly does R make a copy?