[Rcpp-devel] [Rcpp-commits] r220 - in pkg: . inst inst/examples/RcppInline src

Dirk Eddelbuettel edd at debian.org
Tue Dec 29 15:39:58 CET 2009


(bending this one back onto the list...)

On 29 December 2009 at 14:21, Romain François wrote:
| > | Yes, there is the explicit asSexp but you have to call it. operator SEXP
| > | makes it possible to return the RcppSexp and the compiler figures out
| > | that it should return the SEXP instead.
| > |
| > | So instead of this :
| > |
| > | cat("===Doubles\n")
| > | foo<- '
| > |          double d = RcppSexp(x).asDouble();
| > | 	std::cout<<  "Returning twice the value of "<<  d<<  " : ";
| > | 	return(RcppSexp( 2*d ).asSexp());
| > |          '
| > | funx<- cfunction(signature(x="numeric"), foo, Rcpp=TRUE, verbose=FALSE)
| > | cat(funx(x=2.123), "\n")
| > |
| > | We can now do:
| > |
| > | cat("===Doubles\n")
| > | foo<- '
| > |          double d = RcppSexp(x).asDouble();
| > | 	std::cout<<  "Returning twice the value of "<<  d<<  " : ";
| > | 	return(RcppSexp( 2*d ));
| > |          '
| > | funx<- cfunction(signature(x="numeric"), foo, Rcpp=TRUE, verbose=FALSE)
| > | cat(funx(x=2.123), "\n")
| > |
| > | the difference being on the return line.
| >
| > Damn that is nice. And darn close to magic!
| 
| Item 5 of More Effective C++ does not say nice things about it. I'll 
| read it again.

I don't have a copy available right now. What does it say?

| > I was thinking that we may even have enough new stuff to call it 0.8.0
| > instead of 0.7.1.
| 
| sure, please hold the releasing. Right now, I am factoring some things 
| out of RcppSexp into a new class RcppSuperClass which deals with all 
| things that can be related to any SEXP (attributes, is it NULL, 
| protection from GC, ...
| 
| The naming is a bit awkward, maybe RcppSuperClass should be called 

The name is awful :)

| RcppSexp and RcppSexp something else since it really only deals with 
| integer, numeric, character, and raw vectors. Can't call it RcppVector 
| because it already exists. What do you think.

RcppSimple ?
RcppTransfer ?
RcppUtil ?

add a namespace and call it rcpp::Sexp ?  [ I'd rather add a namespace for
all of them at once. And maybe add typedefs to ease transition. To be seen. ]

| > Also, shall we move some of the inline'd tests from inst/examples/RcppInline
| > to tests/ -- possibly with similar RUnit magic as in RProtoBuf ?  We really
| > do use this as unit tests (and that is a good thing).
| 
| Now you start reading my mind.

Yup. But we can do without the unittest vignette. Not sold on that one.

Dirk

-- 
Three out of two people have difficulties with fractions.


More information about the Rcpp-devel mailing list