Alexander Burger <> writes:

Hi Alex,

>> 2. there are many functions in R that look like this:
>> ,--------------------------------
>> | SEXP Invtrans(SEXP pG, SEXP x);
>> `--------------------------------
>> taking two lists, returning one list?
> I don't know the R data structures, but I would say that you should be
> able to do with 'native' almost anything you can do from the C API.
> If 'SEXP' is just a pointer to an opaque data structure, there is not
> much to worry about.

I think thats what it is, at least I remember having read something like

>> 3. what about the many functions of R written in R itself, e.g.
>> ,---------------------------------------------------------------
>> | mean.default <- function(x, trim = 0, na.rm = FALSE, ...){}
>> `---------------------------------------------------------------
> I'm not sure. Then we would need some C-interface to the R runtime
> system (interpreter?), and ways to represent R code in C structures.
>> There is a system of generic functions a bit similar to the CLOS system
>> (dispatching on all arguments). Can these functions be called via
>> 'native'?
> I would think so, as long as they are callable from C. 'native' is not
> more than a mechanism to call C code.

This question is probably redundant, since I found out now that all (?)
the R packages, at least in the defaulft distribution, come with their
own <<package>>.so files. So there is probably never a need to call the
R interpreter. 

> I would recommend to first write some simple programs in C, to get a
> feeling about what needs to be done. Then 'native' can be used to do the
> same from PicoLisp.

Yes, I have to learn some C to make sense out of this. 

> Calling a C library with 'native' without a good understanding what that
> library requires will almost certainly crash the system. For example,
> what is the exact format of arguments and return values? Who "owns" the
> data, i.e. is it necessary to allocate and free memory, or do the
> library functions return pointers to static memory etc.

Thanks for the help



Reply via email to