Re: [Rd] Questions on the R C API

2019-11-05 Thread Gabriel Becker
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 unevalua

Re: [Rd] Questions on the R C API

2019-11-04 Thread Morgan Morgan
Thank you for your reply Jiefei. I think in theory your solution should work. I'll have to give them a try. On Mon, 4 Nov 2019 23:41 Wang Jiefei, wrote: > Hi Morgan, > > My solutions might not be the best one(I believe it's not), but it should > work for your question. > > 1. Have you considere

Re: [Rd] Questions on the R C API

2019-11-04 Thread Wang Jiefei
Hi Morgan, My solutions might not be the best one(I believe it's not), but it should work for your question. 1. Have you considered Rf_duplicate function? If you want to change the value of `a` and reset it later, you have to have a duplication somewhere for resetting it. Instead of changing the

[Rd] Questions on the R C API

2019-11-04 Thread Morgan Morgan
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); ar