[R] Inline Package: void vs return type functions

Dirk Eddelbuettel edd at debian.org
Tue Apr 13 17:55:26 CEST 2010


On 13 April 2010 at 05:46, satu wrote:
| Dear all,
| 
| After having a look at the "inline" package and also going through the
| "Rcpp" package which is tighty related to it, it came to me this question: 
| 
| 1) my C/ C++ code has a return type (let say a double[][] or a user define
| class)

It can;t with the .Call interface from R which requires SEXP.

| 2) I am working with an extensive library built by someone else and  I don't
| have the time/knowledge to change it by means of working with "pointer"
| variables in order to avoid the return sentence,,,
| 
| question A: can I use the -inline- "cfunction" without resorting to the Rcpp
| functionality?

Sure. Inline existed before Rcpp. It can now cooperate (very nicely) with
Rcpp, but is not dependent upon it.

| -- if this is true, question A2: do I need to go deep in the source code
| coming from the library (that I am trying to use) to perform the interface
| through the Rcpp classes?

You could use Rcpp to (more easily) write accessors for your library. You
don;t modify the library, but you write Rcpp-using function that access it
and report back to R.

| questionB: is it true that the working with the -inline- function you have
| to have only void return type code?

False, see above about SEXP and .Call.

| -- if this is false, questionB2: do you have a simple example of this?

There are _hundreds_ of examples in the Rcpp unit tests and a couple more in
the numerous examples.

Rcpp questions should go to the rcpp-devel list; subscribe before posting.

Dirk

 
| Many thanks
| 
| Sergio Barrios
| -- 
| View this message in context: http://n4.nabble.com/Inline-Package-void-vs-return-type-functions-tp1838423p1838423.html
| Sent from the R help mailing list archive at Nabble.com.
| 
| ______________________________________________
| R-help at r-project.org mailing list
| https://stat.ethz.ch/mailman/listinfo/r-help
| PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
| and provide commented, minimal, self-contained, reproducible code.

-- 
  Registration is open for the 2nd International conference R / Finance 2010
  See http://www.RinFinance.com for details, and see you in Chicago in April!



More information about the R-help mailing list