[R] .Call: is new attribute of protected object auto-protected

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat Mar 6 09:02:05 CET 2004


One again, please read the source code to find out.  You are using the
Rdefines.h back-compatibility macros that very few of us use and so almost
all of your audience has no idea exactly what they do (nor AFAIK is that
documented anywhere).  We would have to read the source code for you, and
that is unreasonable.

Since the names<- function does this in R, this should be easy for you to
ascertain.  Note that most of these replacement functions are not quite
the same as setting an attribute, and indeed setting some attributes
(including "names") have special-purpose code.  So your example is
potentially not an example of your subject line.

On Fri, 5 Mar 2004, Vadim Ogranovich wrote:

> I have an SEXP obj in a C function called via .Call(). The obj is
> protected (in fact it is an argument to .Call and therefore
> automatically protected). If I set an attribute of obj does the
> attribute become protected too? Here is an example
>  
> SEXP foo(SEXP obj) {
>     SET_NAMES(obj, NEW_CHARACTER(3));  /* are names protected or not? */
> ...
> }

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list