Rcpp11 / attributes

Standalone implementation of Rcpp attributes.
Other
3 stars 1 forks source link

Handle default arguments for attributes::export #17

Open kevinushey opened 10 years ago

kevinushey commented 10 years ago

Eg. Handle things like

// [[attributes::export]]
void foo(int x = 1, NumericVector y = {1, 2, 3}) { ... }

These need to be parsed into an appropriate R default argument for the wrapper R function generated from compileAttributes

romainfrancois commented 10 years ago

The way this is handled in Rcpp is to somehow convert the c++ code into R code. I think with a bit more logic (with argument matching), we could let C++ do it's thing. In short, in the R layer, or the intermediate c++ generated layer, we'd have to understand how to call the C++ function, and if no parameter is given, then we let C++ use its own default.

So if we call foo( 1L ) then the c++ underlying function is called as foo(1), i.e. the default does not come from R but really where it is expressed, in C++.