[Rd] Questions on the R C API

Morgan Morgan morg@n@em@||box @end|ng |rom gm@||@com
Mon Nov 4 20:40:50 CET 2019


Hi All,

I have some questions regarding the R C API.

Let's assume I have a function which is defined as follows:

R file:

myfunc <- function(a, b, ...) .External(Cfun, a, b, ...)

C file:

SEXP Cfun(SEXP args) {
  args = CDR(args);
  SEXP a = CAR(args); args = CDR(args);
  SEXP b = CAR(args); args = CDR(args);
  /* continue to do something with remaining arguments in "..." using the
same logic as above*/

  return R_NilValue;
}

1/ Let's suppose that in my c function I change the value of a inside the
function but I want to reset it to what it was when I did SEXP a =
CAR(args); . How can I do that?

2/Is there a method to set "args" at a specific position so I can access a
specific value of my choice? If yes, do you have an simple example?

3/ Let's suppose now, I call the function in R. Is there a way to avoid the
function to evaluate its arguments before going to the C call? Do I have to
do it at the R level or can it be done at the C level?

Thank you very much in advance.
Best regards
Morgan

	[[alternative HTML version deleted]]



More information about the R-devel mailing list