>>> On Nov 28, 2009, at 7:50 PM, Guillaume Yziquel wrote:
>>>
>>> FWIW what I think you should be really looking at is
>>> R_PreserveObject/R_ReleaseObject.
>
> OK. Thanks.
>>> I would suggest looking at the many other R embeddings in other
>>> languages that already exist since I don't think you approach
is
>>> very viable (but I think I expressed that already before).
>
> Lisp - the only thing I've seen is a translator:
>
> http://dan.corlan.net/R_to_common_lisp_translator/
>
> I haven't found a binding for Haskell. Nor for Scheme.
>
> Do you know of any bindings of R to functional languages?
It does not have to be a functional language.
To see it in use within a some-language-to-R bridge, you can check the
source in JRI, rpy2.
I can mostly speak for rpy2, and the way it is done there relies on both
R and Python's GC. Creating a anonymous R object presented to the Python
world is first "R_preserved" (from garbage collection from R) then
using
Python's reference counting mechanism, calling an "R_Release"
whenever
the Python wrapper is available for garbage collection (in fact there is
a twist, but this is roughly the way it is working). In your case,
you'll use the OCaml GC system (and "R_release" the R object when
its
OCaml representation is going for garbage collection).
>>> since I don't think you approach is very viable (but I think I
>>> expressed that already before).
>
> You expressed the sentiment that it would be a very bad idea to
> bypass the current API. I would be happy to hear why you would think
> that a low-level binding is not possible, or not very viable.
>
> By low-level, I mean a binding that takes hold of R objects without
> using symbols all over to reference them. (Using symbols in the
> formals, the body or the environment of a closure is fine, for
> instance, but I'd like to execute a closure directly, and eventually
> be able to construct R closure from OCaml functions).
Rpy2 can do a lot of that, and probably so can JRI.
> Please elaborate on the difficulties you perceive. That would be
> helpful.
Symbols are used in various places in R, checking the outcome of
deparse(substitute()) on an anonymous variable of large size could tell
you that some things will not work out of the box nicely.
HTH,
L.
>>> Cheers, Simon
>
> All the best,
>
> Guillaume.
>
> -- Guillaume Yziquel http://yziquel.homelinux.org/