[Rcpp-devel] What is the best practice to expose a C structure from 3rd

Dirk Eddelbuettel edd at debian.org
Mon Jul 22 16:56:32 CEST 2013


On 22 July 2013 at 09:31, Steve Jaffe wrote:
| On: Mon, 22 Jul 2013 16:12:54 +0800
| Wush Wu <wush978 at gmail.com> wrote:
| 
| > Subject: [Rcpp-devel] What is the best practice to expose a C
| > 	structure from 3rd party library into R?
| 
| > However, I still want to know if there is a better approach. I tried three
| > approaches. 
| 
| Have you considered the 'rdyncall' package as an alternative for wrapping an existing C library? 
| 
| I have no personal experience but it looks extremely interesting, especially considering the list
|  of libraries, some quite large, which have been successfully ported, as described in:
| 
| http://journal.r-project.org/archive/2012-1/RJournal_2012-1_Adler.pdf
| 
| If you do try it, I'd be interested in knowing what you think.

rdyncall is a very interesting package, and Daniel is an extremely gifted and
knowledgeable R and C hacker.

But my main problem with this approach is ... that you get /no/ type
conversion whatsoever.  And for me life is too short to untangle SEXP
expressions by hand if the existing Rcpp classes do it so well "for free". I
do want to pass entire R vectors, matrices, lists, data.frames, environments,
functions ... with ease between both systems.  Rcpp lets me do that. 

I built Wush's 'Rhiredis' package on the train to work, and will have some
comments / variants.  I think it will make a nice example for 'how to expose
a C structure' (see Subject:; and I had been asked that in private mail
recently too).  

So I may just fork his repo to provide a base example and Rcpp Gallery post
on the topic as it has come up repeatedly.  And hacking on Redis looks like
fun anyway as the API is so neat.

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list