Thank you Gabor.  Yes, I've looked at the Ocaml-R bindings.  They are in
fact where I got the notion that the integration of two garbage collection
systems can be tricky.  Guillaume Yziquel, the author of the Ocaml-R
bindings wrote to me that:

"As for speed, currently, there's a very inefficient interaction between
OCaml's GC and R's GC. If you have n R values that are being held by
OCaml, you free each value in O(n), meaning quadratic time to free the
whole bunch. There is a solution to this, but I did not find the time to
implement it. And of course, the speed is only on the OCaml side, not on
the R side."

and hence I am especially conscious of the traps for the unwary when
integrating two GCs.


On Sat, Dec 11, 2010 at 9:19 PM, Gabor Grothendieck <ggrothendieck@gmail.com
> wrote:

> On Sat, Dec 11, 2010 at 9:04 PM, Jason E. Aten <j.e.aten@gmail.com> wrote:
> > I'd like to develop, if there is not one already, an interface between R
> > code and Haskell code, to allow R code to call Haskell (compiled) code,
> and
> > vice-versa.  But in the interest of not reinventing the wheel, does
> anyone
> > on this list know of existing bindings for Haskell code?
> >
> > There is support for loading plugins in Haskell, and for an eval() like
> set
> > of functions provided by the Haskell hs-plugin package that evaluates
> > arbitrary strings in the IO monad.
> > http://www.cse.unsw.edu.au/~dons/hs-plugins/paper/<http://www.cse.unsw.edu.au/%7Edons/hs-plugins/paper/>describes this
> > functionality. For example:
> >
> > #include <stdio.h>
> > #include "RunHaskell.h"
> >
> > int main(int argc, char *argv[]) {
> >  int *p;
> >  hs_init(&argc, &argv);
> >  p = hs_eval_i("foldl1 (+) [0 .. 10]"); /* this is Haskell code */
> >  printf("%d\n", *p); hs_exit();
> > }
> >
> >
> >
> > That said, i don't think it will be that difficutl.  But I imagine the
> > hardest part of this will be getting the memory management for garbage
> > collection right. I thought I would start by looking at how the rJava or
> > rJython packages handle memory. If anyone has pointers or advice on
> > integrating R's garbage collection with another language's garbage
> > collection, I'd welcome suggestions and warnings about pitfalls.
> >
>
> You might look at:
>
> http://home.gna.org/ocaml-r/
>
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com
>

	[[alternative HTML version deleted]]

