Re: [Rcpp-devel] Default value for Rcpp List

2013-08-14 Thread Dirk Eddelbuettel
On 14 August 2013 at 15:57, Matteo Fasiolo wrote: |  thank you very much for your replies. In the end a named vector is | enough for my purpose: | | cppFunction( |   ' |   NumericVector myVett(NumericVector x = NumericVector::create(0) ) |  { |   if(x.size() == 0) x = NumericVector::create(_["a"

Re: [Rcpp-devel] Default value for Rcpp List

2013-08-14 Thread Matteo Fasiolo
Dear Dirk and JJ, thank you very much for your replies. In the end a named vector is enough for my purpose: cppFunction( ' NumericVector myVett(NumericVector x = NumericVector::create(0) ) { if(x.size() == 0) x = NumericVector::create(_["a"] = 1.0, _["b"] = 2.0); return x; } ' ) myVe

Re: [Rcpp-devel] Default value for Rcpp List

2013-08-14 Thread JJ Allaire
Hi Matteo, The issue here is that the Rcpp attributes code that parses function declarations isn't able to parse all syntactic forms of C++ but rather a subset. The default argument parsing is able to handle scalars, strings, and simple vector initializations but not more complex expressions like

Re: [Rcpp-devel] Default value for Rcpp List

2013-08-14 Thread Dirk Eddelbuettel
On 14 August 2013 at 11:42, Matteo Fasiolo wrote: | Dear Rcpp users, | |  a very simple question: I have a function that has a Rcpp::List | among its arguments, and I would like to set a default values for | that List. | Unfortunately this code: | | cppFunction( |   ' |   List myList(List x = Li

[Rcpp-devel] Default value for Rcpp List

2013-08-14 Thread Matteo Fasiolo
Dear Rcpp users, a very simple question: I have a function that has a Rcpp::List among its arguments, and I would like to set a default values for that List. Unfortunately this code: cppFunction( ' List myList(List x = List::create(_["a"] = 1, _["b"] = 2)) { return x; } ' ) raises the