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: logical vector > - STRSXP: character vector > - ... (and a dozen more)
I do not really understand the implications in the context of R, but Pil21 has a new 'T' result specification for raw Lisp data. It allows to pass a pointer to any Lisp data item to a native function, and/or to return such data. > When I have an imaginary generic C function like this: > > SEXP fun(SEXP x, char * cmd) As an example, we might call the standard 'prog1' function in the Pil21 executable (which has the internal label "_prog1", try (vi 'prog1)). It takes a list for the body, and returns the resulting value: : (%@ "_prog1" T '(T prog1 7 (println 1 2 3))) 1 2 3 -> 7 This is equivalent to : (prog1 7 (println 1 2 3)) 1 2 3 -> 7 > how can I specify Return Value/Arguments in a 'native' call, if I cannot > know in advance to which R subtype the SEXP Points? If the above is not what you intended, the 'P' result specification can be used as an unspecific pointer (void*, an unsigned 64 bit number). ☺/ A!ex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe