[Rd] Experimental R_has_slot() utility
Laurent Gautier
lgautier at gmail.com
Sat Mar 15 22:46:27 CET 2008
2008/3/16, Martin Maechler <maechler at stat.math.ethz.ch>:
> >>>>> "LG" == Laurent Gautier <lgautier at gmail.com>
> >>>>> on Sat, 15 Mar 2008 16:24:26 +0800 writes:
>
> LG> Dear list, The utility "R_has_slot" mentioned in the
> LG> file NEWS ("Experimental R_has_slot() utility
> LG> supplementing R_do_slot()") appears to be missing from a
> LG> fresh checkout of the development branch.
>
> LG> $ svn up At revision 44759. $ grep -i has_slot `find
> LG> include -name '*.h'` $ grep -i _slot `find include -name
> LG> '*.h'` include/Rdefines.h:#define GET_SLOT(x, what)
> LG> R_do_slot(x, what) include/Rdefines.h:#define
> LG> SET_SLOT(x, what, value) R_do_slot_assign(x, what,
> LG> value) include/Rinternals.h:SEXP R_do_slot(SEXP obj,
> LG> SEXP name); include/Rinternals.h:SEXP
> LG> R_do_slot_assign(SEXP obj, SEXP name, SEXP value);
>
>
> LG> ..or did I miss it ?
>
> Yes. It's been so much experimental as not even making it into
> a header ... arguably an oversight.
> It's in src/main/attrib.c
>
> int R_has_slot(SEXP obj, SEXP name)
>
> It's not used anywhere currently in our own code,
> but I had seen interesting use cases more than once.
>
> Would you want to use it in your own code?
Yes.
My use-case is with a Python-R interface. For the low-level part
of it I am trying to use C-level functions for the common/frequent operations
- speed concerns-. With that function I can test whether the
attribute exists, and raise an exception if it does not.
Following your comment that it could have made it to a header, I
already started using it and it is doing what I am expecting from it
(according to my limited unit-tests).
Thanks,
L.
> Regards, Martin
>
More information about the R-devel
mailing list