Are there examples of SEXP declarations in Rcpp?

Viewed 2409

I read in Hadley Wickham's book that RObjects should be declared as S-expressions (SEXP) in R's C API:

SEXP x( SEXP a, SEXP b {
}

In Rcpp, however, it seems this necessity is over. In other words, functions should be declared with some defined datatype, for example:

NumericVector x(NumericVector a, NumericVector b) {
 }

Are there examples where SEXP declarations are still useful in Rcpp's context?

1 Answers

Yes of course as everything gets translated to/from SEXP. In some cases we opt to keep a SEXP.

A 'classic' example is the run-time switching on type (where it shows a List but you can do the same with a single SEXP). Other examples are the as<> and wrap() converters.

And ... of course code where users chose to keep a SEXP. You can search at the Rcpp Gallery for more examples, and/or of course also search here among the almost 2000 questions for Rcpp.

Related