<div dir="ltr">Dear Rcpp users,<div><br></div><div> a very simple question: I have a function that has a Rcpp::List</div><div>among its arguments, and I would like to set a default values for</div><div>that List.</div><div>
Unfortunately this code:</div><div><br></div><div><div>cppFunction(</div><div>  '</div><div>  List myList(List x = List::create(_["a"] = 1, _["b"] = 2))</div><div> {</div><div>  return x;</div><div>
 }</div><div> ' </div><div>)</div><div><br></div></div><div>raises the warning:</div><div><br></div><div><span class="" style="border-collapse:separate;border-spacing:0px;background-color:rgb(225,226,229)"><pre tabindex="0" class="" style="outline:none;border:none;margin-top:0px;margin-bottom:0px">
<span class="" style="border-collapse:separate;border-spacing:0px"><pre tabindex="0" class="" style="outline:none;border:none;margin-top:0px;margin-bottom:0px"><span class="" style="color:rgb(197,6,11);font-family:'Ubuntu Mono';font-size:10.4pt!important;line-height:1.2;white-space:pre-wrap!important">Warning message:
</span><span class="" style="color:rgb(197,6,11);font-family:'Ubuntu Mono';font-size:10.4pt!important;line-height:1.2;white-space:pre-wrap!important">Unable to parse C++ default value 'List::create(_["a"] = 1, _["b"] = 2)' for argument x of function myList 
</span><span class=""><font color="#0000ff" face="Ubuntu Mono"><span style="font-size:14px;line-height:16px">> 
> myList()</span></font><font color="#0000ff" face="Ubuntu Mono" size="3"><span style="line-height:1.2;white-space:pre-wrap!important">
</span></font></span><span class="" style="color:rgb(197,6,11);font-family:'Ubuntu Mono';font-size:10.4pt!important;line-height:1.2;white-space:pre-wrap!important">Error in .Primitive(".Call")(<pointer: 0xb5907fb0>, x) : 'x' is missing</span></pre>
</span></pre></span></div><div><br></div><div>Similar code with NumericVector works fine:</div><div><br></div><div><div>cppFunction(</div><div>  '</div><div>  NumericVector myVett(NumericVector x = NumericVector::create(3))</div>
<div> {</div><div>  return x;</div><div> }</div><div> ' </div><div> )</div><div><br></div><div>myVett()</div></div><div><div># [1] 0 0 0</div><div><br></div><div>Am I doing something wrong? Thanks!</div></div></div>