Hi Thorsten,
> Question on topic 2:
> given the C data type described below for an R "node", would it be somehow
> possible to extract just the SEXPTYPE from a SEXP return value, i.e.
> the first field of the sexpinfo_struct, that is the first struct in the
> SEXPREC_HEADER, that is the first
Picolisp has "native" calls as an FFI to call C shared libraries from
Picolisp, and build Picolisp wrapper functions on top of C functions
defined in header files.
A lot of programming languages allow that, there are e.g. many Python
wrappers for all kinds of data science libraries. But with
So, if I understand correctly we could use the introspective power of
picolisp and write a {meta?}program to produce the "library" for Pil, and
then use this to call R from picolisp?
--
Cesar Rabak
On Thu, Apr 8, 2021 at 4:14 PM Thorsten Jolitz wrote:
> Hi Alex,
> after digging deeper in R
Hi Alex,
after digging deeper in R Internals I found out that there are actually C
access functions for the various subtypes of SEXP that can be wrapped with
native too:
rinc: (setupRinC)
-> NIL
rinc: (evalQuietlyInR "V <- c(1.5, 3.4, 4.2)")
-> NIL
rinc: (evalInR "V")
-> 65007640
rinc: (REAL
On Wed, Apr 07, 2021 at 07:46:20AM +0200, Alexander Burger wrote:
> OK, so now we have a pointer to a structure filled by evalInR().
> ...
>(struct (evalInR "6*4") ...)
In fact this depends on what exactly evalInR() returns.
If it returns a pointer to a dynamically allocated structure, and
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
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
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
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
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:
Hello List,
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: logical vector
-
11 matches
Mail list logo