[Rcpp-devel] number of arguments

Romain Francois romain at r-enthusiasts.com
Thu Feb 11 14:23:50 CET 2010


Hello,

Some time ago, I commited some code bloat so that we are less dependent 
on variadic templates for :
- creating Pairlist objects
- creating Language objects
- calling Function

So for example instead of the catch all so cool variadic template ;

template<typename... Args>
	SEXP operator()( const Args&... args) /* throw(Evaluator::eval_error) */ {
		return internal::try_catch( Rf_lcons( m_sexp, pairlist(args...) ) ) ;
	}

I've added a bunch of methods like this :

template <typename T1>
SEXP operator()( const T1& t1){
	return internal::try_catch( Rf_lcons( m_sexp, pairlist(t1) ) ) ;
}
template <typename T1, typename T2>
SEXP operator()( const T1& t1, const T2& t2){
	return internal::try_catch( Rf_lcons( m_sexp, pairlist(t1,t2) ) ) ;
}
...
template <typename T1, typename T2, typename T3, typename T4, typename T5>
SEXP operator()( const T1& t1, const T2& t2, const T3& t3, const T4& t4, 
const T5& t5){
		return internal::try_catch( Rf_lcons( m_sexp, pairlist(t1,t2,t3,t4,t5) 
) ) ;
}
/* </code-bloat> */


The question is : is 5 enough ? should it be 10 ? 20 ?
Those are templates so they are only instanciated when requested, so I 
don't have an issue about having an higher number.

Romain

-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/NrTG : Rcpp 0.7.5
|- http://tr.im/MPYc : RProtoBuf: protocol buffers for R
`- http://tr.im/KfKn : Rcpp 0.7.2



More information about the Rcpp-devel mailing list