Skip to content

[Rcpp-devel] Rcpp::Function

3 messages · Romain Francois, Dirk Eddelbuettel

#
Just to give an example of Rcpp::Function :

 > funx <- cfunction(signature(), '
+ Environment stats_namespace = Environment::namespace_env("stats") ;
+ Function rnorm( stats_namespace.get("rnorm") ) ;
+ return rnorm( 10, Named("sd", 100) ) ;
+ ', Rcpp=TRUE, verbose=FALSE, includes = "using namespace Rcpp;" )
 >
 > funx()
  [1]   19.4633261 -121.6885863   34.7072963   -7.1155573  -33.4987573
  [6]  -73.0344024  -58.9558195   -0.3289519   81.7164016  151.8835010


One thing we are going to have to do at some point is some examples 
somewhere. We have lots of unit tests, but maybe it would be worth 
having some C++ only examples (without the inline trick) to show the API.

Romain
#
On 4 January 2010 at 23:59, Romain Fran?ois wrote:
| Just to give an example of Rcpp::Function :
| 
|  > funx <- cfunction(signature(), '
| + Environment stats_namespace = Environment::namespace_env("stats") ;
| + Function rnorm( stats_namespace.get("rnorm") ) ;
| + return rnorm( 10, Named("sd", 100) ) ;
| + ', Rcpp=TRUE, verbose=FALSE, includes = "using namespace Rcpp;" )
|  >
|  > funx()
|   [1]   19.4633261 -121.6885863   34.7072963   -7.1155573  -33.4987573
|   [6]  -73.0344024  -58.9558195   -0.3289519   81.7164016  151.8835010
| 
| 
| One thing we are going to have to do at some point is some examples 
| somewhere. We have lots of unit tests, but maybe it would be worth 
| having some C++ only examples (without the inline trick) to show the API.

Yup. We are already beyond the point of an R Journal or JSS article and is
narrowing a short book, and it only gets worse.  Tell me when you code up
Time::Machine and we take a timeout and document all this properly.

Dirk
#
On 01/05/2010 12:22 AM, Dirk Eddelbuettel wrote:
I'd like to have a go at vectors: integer, numeric, raw, character, 
expression, complex, generic (lists).

S4 (S4SXP) I'll do some stuff about slot management. Although we need to 
be careful because some S4 objects don't have the S4SXP SEXPTYPE.

weak references (WEAKREFSXP) I don't know what they do, so i'll write a 
class but it will be a dummy.

byte code (BCODESXP) I have no idea what this is

DOTSXP and ANYSXP not sure how to cover them


Here's what I propose. Let's get something done for vectors, release 
0.7.2 and then start to wear some documenting shoes. I really don't want 
to get into the hoops of branching, etc ...

Beyond the joke, I think this would make a terrific article for JSS or R 
journal, and also a good useR presentation. (I'd also like to present 
RProtoBuf this year, so we need to find some way of dealing with the 
'one presentation per speaker' rule)

Romain