Aaron J Mackey wrote:
> 
> On Sat, 10 Feb 2001, Brian Ingerson wrote:
> 
> > I would suggest starting with Inline::R to get more support from the
> > community. Our community that is. Your community might benefit more from
> > Inline::S, but you can probably port to that afterwards.
> 
> Well having skimmed through the R material this afternoon, here's what I

I played with R last night too. The demos were amazing. I'm definitely a
proponent of gluing this thing to Perl. Not only would it be good for R,
but it I think it could help Perl see more action in academia and the
sciences.

> now know: R is very much like Perl in the sense that it is an interpreted
> language whose guts have a continually evolving API, and way to dynaload

So as far as Inline goes, here is what you'll want to achieve:

1) Be able to parse R code to find functions. Either:
   1) Use something like Parse::RecDescent
   2) Better yet, use R to parse R and return a list of functions.
That's what Neil Watkiss does with Inline::Python. You'll need to figure
out how.
2) Have some/all inlined R functions bind to Perl as subroutines or
methods.
3) Provide translation between simple data types. (It seems like R
variables should always translate to Perl array refs.)
4) Keep it as simple as possible to start with.

> external packages into R.  I have not yet found any discussion of
> embedding R into C, only of writing C extensions callable by R, and the

Neil says it should be no problem to embed. (He's a real whiz kid.) With
his help we'll be up and running in no time. I was able to build R as a
shared library using: 

    ./configure --enable-R-shlib

> various nitty-gritty that goes along with it (which reminds me terribly of
> XS).

You'll need to do the nitty-gritty. Inline only spares its _users_ of
that aspect :)

Actually a good place to start hacking would be to use Inline::C to talk
to libR.so. I like that. Using Inline to bootstrap new Inline ILSMs.

Cheers, Brian

PS Here's a sample that calls a math 'gamma' function from R. At least
it's a place to start.

----8<----
use Inline C => DATA => 
           LIBS => '-L/usr/local/lib/R/bin -lR',
           INC => "-I/usr/local/lib/R/include/",
           PREFIX => 'my_';

print dgamma(1, 2, 3, 4), "\n";

__END__
__C__
#include "Rmath.h"

double my_dgamma(double a, double b, double c, int i) {
    return dgamma(a, b, c, i);
}
----8<----


-- 
perl -le 'use Inline C=>q{SV*JAxH(char*x){return newSVpvf
("Just Another %s Hacker",x);}};print JAxH+Perl'

Reply via email to