Is this macro intended to be used in other, similar contexts? Otherwise, why not have "switch" inside unique2, as in Hadley's original code?
Davor On 2012-11-22, at 7:25 AM, Hadley Wickham wrote: >> #define DISPATCH_METHOD(method, x) \ >> switch( TYPEOF(x) ){ \ >> case REALSXP: \ >> return method<REALSXP>(x); \ >> case INTSXP: \ >> return method<INTSXP>(x); \ >> case STRSXP: \ >> return method<STRSXP>(x); \ >> case LGLSXP: \ >> return method<LGLSXP>(x); \ >> default: \ >> Rf_error("Unsupported type"); \ >> return x; \ >> } > > Why do we need a macro here? Is it not possible to pass in method as a > function? It seems like there must be a more elegant way to do > dynamic dispatch. > > Hadley > > > -- > RStudio / Rice University > http://had.co.nz/ > _______________________________________________ > Rcpp-devel mailing list > Rcpp-devel@lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel