<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Le 17 juil. 2013 à 13:41, JJ Allaire <<a href="mailto:jj.allaire@gmail.com">jj.allaire@gmail.com</a>> a écrit :</div><div><br></div><blockquote type="cite"><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">dispatching could also happen in attributes. Why not having something like this:<br>
<br>
// [[Rcpp::export]]<br>
void foo( NumericVector x) {<br>
    // do some stuff<br>
}<br>
<br>
// [[Rcpp::export]]<br>
void foo( IntegerVector x) {<br>
    // do some other stuff<br>
}<br>
<br>
This would involve some work in the way attributes work. But I can defintely see the value of this. Comments. JJ ?<br></blockquote><div><br></div><div>Yes, agreed, this would be really cool! I don't think it's in principle difficult to do.</div></div></div></blockquote><div><br></div>Same here. I'm sort of off the grid for a few days now, resting from about 3weeks of travelling. <div><br></div><div>I'll have a look later then. </div><div><br></div><div>Another extension i had in mind, well i think hadley mentionned it in Lyon was the ability somehow to export templates. </div><div><br></div><div>template <int RTYPE></div><div>Vector<RTYPE> foo( Vector<RTYPE> x){</div><div>    // do stuff</div><div>}</div><div><br></div><div>At the moment, if we have a function like this, we have to write the dispatcher sort of manually with a switch(TYPEOF)) construct. </div><div><br></div><div>The issue then i guess is to find the right way to express which instantiations of the template we export, maybe something like : </div><div><br></div><div>// [[Rcpp::exportTemplate(INTSXP,REALSXP)]]</div><div><br></div><div><br></div><div>But maybe it is not worth the trouble. Maybe this is simply a documentation issue on hiw to dispatch. </div><div><br></div><div>Romain</div></body></html>