Version française
Home     About     Download     Resources     Contact us    
Browse thread
R bindings ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Bünzli_Daniel <daniel.buenzli@e...>
Subject: Re: [Caml-list] R bindings ?

Le 16 mars 08 à 20:01, Maxence Guesdon a écrit :

> Because
> - Printf-ing the code is kind of heavy and error-prone,
> - parsing the computed values is some work to handle correctly,
> - the compiler can't tell me if I did something wrong so I get all  
> the errors at execution time.

This need not be the case if you apply language embedding/meta- 
programmation techniques (see for example [1]). You can even mask R  
computations behind plain caml functional types.

I have an unpolished toy example that does this to program arithmetic  
functions on regular ocaml types but that use scsh to actually compute  
the result (no camlp4 or unsafe features required), I can forward it  
to you if you are interested.

Here's an example of a polymorphic cube function, when you invoke  
cubei or cubef the result will actually be computed by scsh. The  
drawback is that you need to "write" the type your functions by hand  
(cf argi argf reti retf).

open Mini
open Override
open Program

let cube_s = fun x -> x * x * x

let cubei_p = compile (argi (reti cube_s))
let cubef_p = compile (argf (retf cube_s))

let cubei : int   -> int   = as_fun cubei_p
let cubef : float -> float = as_fun cubef_p

However as Ashish pointed out the biggest problem are the data sets,  
but it may be that you can keep them in R only with suitable types to  
represent them in ocaml.




   author = {Conal Elliott and Sigbj\&\#248;rn Finne and Oege De Moor},
   title = {Compiling embedded languages},
   journal = {J. Funct. Program.},
   volume = {13},
   number = {3},
   year = {2003},
   issn = {0956-7968},
   pages = {455--481},
   doi = {},
   publisher = {Cambridge University Press},
   address = {New York, NY, USA},