[Rd] package: 'inline' to inline C or C++ code in R functions
murdoch at stats.uwo.ca
Wed May 23 19:36:12 CEST 2007
On 5/23/2007 11:52 AM, Oleg Sklyar wrote:
> Dear all,
> following the earlier discussion, I've made a couple of changes to
> 'inline' (http://www.ebi.ac.uk/~osklyar/inline). As announced before the
> idea of the package is to enable inlining C or C++ code in R functions
> using only R sources. The changes include:
> - it is possible to select between C and C++
> - it is possible to declare a standard R function calling a C/C++
> routine or an S4 method with a fixed signature
> - setCMethod accepts single of multiple method signatures in a list, all
> put in one shared object
> - readline syntax is used in the example for a multiline C++ source :)
> Thanks Duncan, Simon and Deepayan for useful comments!
> Not tested on Windows, I would be thankful if somebody could do it.
It doesn't quite work there. There are two problems: the test for
windows should be based on .Platform$OS.type, and R CMD SHLIB expects
filenames with Unix-style path separators. I've attached a patch.
Other suggestions: instead of relying on the filename for lookup when
calling the compiled code, you might want to use getNativeSymbolInfo to
obtain it right after compiling. This can be used as the name argument
in .Call, but will avoid doing another lookup in the DLL, possibly
finding a name clash.
You were asking how to handle automatic unloading: I haven't done this
myself, but I think RODBC does something similar to close database
Something else you might want to think about: if someone saves one of
your cfunction results, you may need to recompile it when they reload.
Thanks for writing this, it's looking really nice.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the R-devel