[Rcpp-devel] is<T>( SEXP )

Romain Francois romain at r-enthusiasts.com
Wed Jul 17 13:56:22 CEST 2013


Le 17 juil. 2013 à 13:41, JJ Allaire <jj.allaire at gmail.com> a écrit :

>> dispatching could also happen in attributes. Why not having something like this:
>> 
>> // [[Rcpp::export]]
>> void foo( NumericVector x) {
>>     // do some stuff
>> }
>> 
>> // [[Rcpp::export]]
>> void foo( IntegerVector x) {
>>     // do some other stuff
>> }
>> 
>> This would involve some work in the way attributes work. But I can defintely see the value of this. Comments. JJ ?
> 
> Yes, agreed, this would be really cool! I don't think it's in principle difficult to do.

Same here. I'm sort of off the grid for a few days now, resting from about 3weeks of travelling. 

I'll have a look later then. 

Another extension i had in mind, well i think hadley mentionned it in Lyon was the ability somehow to export templates. 

template <int RTYPE>
Vector<RTYPE> foo( Vector<RTYPE> x){
    // do stuff
}

At the moment, if we have a function like this, we have to write the dispatcher sort of manually with a switch(TYPEOF)) construct. 

The issue then i guess is to find the right way to express which instantiations of the template we export, maybe something like : 

// [[Rcpp::exportTemplate(INTSXP,REALSXP)]]


But maybe it is not worth the trouble. Maybe this is simply a documentation issue on hiw to dispatch. 

Romain
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130717/ee836243/attachment.html>


More information about the Rcpp-devel mailing list