Hi Martin and Jiefei, A quick note, I'll try to respond more completely later.
> It is a primitive but I don't understand how it manage to do that. > Primitives and Internals are allowed to be, but usually aren't, SPECIALSXPs rather than BUILTINSXPs. SPECIALSXPs receive their arguments unevaluated when called from R. See https://cran.r-project.org/doc/manuals/r-release/R-ints.html#g_t_002eInternal-vs-_002ePrimitive. This is not possible for functions that are not part of the R sources as far as I know. Also the difference between Primitives and internals isn't evaluation of arguments (thats special vs builtin) but rather, whether they behave like a closure (internal) or not (primitive). Evaluation behavior for internal and primitive functions is defined within the function table in names.c, the comment there explains the format. Best, ~G > > Best, > Morgan > > > > > Best, > > Jiefei > > > > > > On Mon, Nov 4, 2019 at 2:41 PM Morgan Morgan <morgan.email...@gmail.com> > > wrote: > > > >> 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]] > >> > >> ______________________________________________ > >> R-devel@r-project.org mailing list > >> https://stat.ethz.ch/mailman/listinfo/r-devel > >> > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > [[alternative HTML version deleted]] ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel