Hi Thorsten,
> I wonder how to deal with the R SEXP Data structure in native calls.
>
> *"Technically, [a SEXP] is a pointer to a structure with typedef SEXPREC.
> A SEXP is a variant type, with subtypes for all R’s data structures"*
>
> E.g.
>
>- INTSXP: integer vector
>- LGLSXP: logic
Hi Thorsten,
The quote you copied here (coming from the ref. of yours R's C Interface),
describes IIUC a structure, more accurately the model of, for calling
"foreing" C functions in R and not the converse.
The way to call R functions in picolisp would be to call the functions made
available thro
Hi Alex,
thanks for the hints, I tried both, T and 'P as result values , the first
gives a segment fault, but the second actually works:
(de evalInR ("Cmd")
(native `*RinC "evalInR" 'P "Cmd"))
## SEXP evalInR(char * cmd);
rinc: (evalInR "print(6*4)")
[1] 24
-> 65814160
If I use "print"
Hi Cesar,
it works both ways, and there is an old R C API and more modern C++
implementations (with C headers too) for the use case here:
- call R from C(++).
or better:
- call R from PicoLisp via (native) C (calls)
See my last answer to Alex to see that the call to R actually works.
Cheers
Thorst
Hi Thorsten,
> (de evalInR ("Cmd")
> (native `*RinC "evalInR" 'P "Cmd"))
>
> ## SEXP evalInR(char * cmd);
>
> rinc: (evalInR "print(6*4)")
> [1] 24
> -> 65814160
OK, so now we have a pointer to a structure filled by evalInR().
> rinc: (evalInR "6*4")
> -> 65814160
>
> how can I extra