[Rd] [ANN] OCaml-R binding for the R language.
guillaume.yziquel at citycable.ch
Fri Feb 12 23:02:41 CET 2010
This post is to announce the 0.2 release of OCaml-R.
OCaml-R is a binding embedding the R interpreter into Objective Caml code.
Home page: http://home.gna.org/ocaml-r/
Download page: http://download.gna.org/ocaml-r/
Deb packages: http://yziquel.homelinux.org/debian/pool/main/o/ocaml-r/
OCamlDoc API: http://yziquel.homelinux.org/topos/api/ocaml-r/index.html
The goal of OCaml-R is to provide adequate integration of the R
interpreter into Objective Caml, and a framework suitable to bind R
library into OCaml code.
Version 0.2 is a near-complete rewrite of the 0.1 version by Maxence
Guesdon, with an incompatible API. Main features are:
- Safe handling of R default environment variables at compile time,
following what is done in littler.
- R Signal handlers do not conflict with OCaml code.
- Integration with findlib, enabling the #require "R.interpreter" to
initialise statically the R interpreter. Compiling with 'ocamlfind
ocamlopt -package R.interpreter' also initialises the R interpreter at
compile-time, so to speak.
- Some (most?) functionalities of the R standalone library are wrapped.
- Low-level binding, in the sense that you construct low-level R calls
to execute them. You can also parse R code to execute it, if you wish.
- R exceptions are chained back to Objective Caml.
- R's garbage collector is chained with OCaml's garbage collector. This
is done rather inefficiently for the moment (freeing n R values in
O(n^2) time complexity), and we expect to bring this down to O(n) with a
thin garbage collecting layer in the future.
- We provide a double typing scheme, with some subtyping features. A
first typing mimics the dynamic typing of the R language, while a second
typing, for the end-user, aims at providing a static typing of R values
and functions. (This can be bettered).
- S3 classes are supported (static typing is however still
unsatisfying). S4 classes are not yet supported. Help welcome.
- Some basic R datatypes, such as dataframes, are wrapped, and a
framework to wrap the standard library has been put in place.
- Basic data structures can be converted back and forth between OCaml
and the R interpreter.
- Ability to inspect (read-only) the inner structure of R values, which
is quite convenient: you get to know rather quickly what a given piece
of R code returns, which you need to know to type R code statically in
order to bind it to OCaml.
- Not thread-safe at all. At least, not more than R is... Lwt-style
multithreading of R code could be possible, modulo some simple and deep
(i.e. below R API) changes in the R evaluation functions. POSIX
threading a single R thread with multiple OCaml threads is not yet
possible, but is within reach.
- Doesn't interact well the R "Defaults" package.
While most of the code sticks or could stick to the R API, or at least
to the public part of the R headers, there are some functionalities
which are outright out of the scope of the R API. Some of these
functionalities are for convenience only (i.e. inspecting internals of R
values), while others are crucial to the binding (chaining R exceptions
Hopefully, this lays down a foundation on which one could import R
functionalities, libraries and packages to OCaml.
More information about the R-devel