[Rd] How to get an object name from C?

Daniel Cegiełka d@n|e|@ceg|e|k@ @end|ng |rom gm@||@com
Sat Jan 18 10:36:47 CET 2020


(earlier I sent it as html by mistake).

Hi,

How can I get from C an object name used as a function argument? I
have sample code in C that gives me access to the name of the function
being called:


SEXP xname(SEXP x)
{
        const char *fun_name = CHAR(PRINTNAME(CAR(x)));
        x =  CDR(x);
        const char *arg_name = isNull(TAG(x)) ? "" : CHAR(PRINTNAME(TAG(x)));

        Rprintf("fn_name: %s, arg_name: %s\n", fun_name, arg_name);
        return R_NilValue;
}


> xname <- function(...) invisible(.External("xname", ...))
>
> x1 = 123
>
> xname(x1)
fn_name: xname, var_name:


However, I am trying to find a way to access the object name. In the
documentation I found a solution for named args:


> xname(arg = x1)
fn_name: xname, var_name: arg


And I'd like to find the equivalent in C for substitute():

> substitute(x1)
x1


Best regards,
Daniel



More information about the R-devel mailing list