[Rd] Samples of external code with various compilers?

ripley@stats.ox.ac.uk ripley@stats.ox.ac.uk
Mon Dec 2 09:08:06 2002


On Sun, 1 Dec 2002, Duncan Murdoch wrote:

> R can run external code in C, C++, Fortran, Delphi, etc., but the R
> extensions manual only gives limited documentation for anything but C
> and C++.  It would be useful to have a collection of sample code
> showing how to dyn.load functions written in other languages, if
> necessary for a variety of different compilers, in case that makes a
> difference.

I think there is information and lots of examples already for Fortran. I
am not sure what more there is to say in `Writing R Extensions'. We could
point at an example in the R code I you think it would be helpful.  But
I'm puzzled here as to what you find lacking. (Fortran is supported both
via .Fortran and by some of the functions described in the section on the
R API.)

> Does such a collection already exist?  If not, would it be better to
> put it into the R extensions manual as a series of appendices, or just
> have a web page about it?

Base R has only interfaces for C and Fortran (and that via C-style
linkage): SJava adds .Java.  So is the issue how to write in other
languages to use a C interface?  `how to dyn.load functions' is easy: you
just create an appropriate compiled object, a shared library, a DLL or (on
MacOS X as I understand it) a module.  The issues seem to be to export the
symbols correctly, and even more to import ones from R correctly,

I will be interested to hear if there are any other (than Java) candidate
languages that are widely available.  Delphi as I understand it is
Windows-only (and the related Kylix is Linux-only?).  Information on using
Delphi would be very helpful in the R for Windows documentation, but you
are one of the experts there.

Brian

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595