Hi, <div><br></div><div>For a Rcpp::List object, the attributes got lost say if I add another element to the list.  I am not sure this is supposed to be, but it's not in R.  The following is some code to demonstrate that. </div>
<div><br></div><div><div>> library(Rcpp)</div><div>> src <- '</div><div>+ #include <Rcpp.h></div><div>+ // [[Rcpp::export]]</div><div>+ SEXP crtlist() {</div><div>+   Rcpp::List lst;</div><div>+   lst["e1"] = 10;</div>
<div>+   lst.attr("att1") = 1;</div><div>+   return lst;</div><div>+ } </div><div>+ '</div><div>> sourceCpp(code = src)</div><div>> crtlist();</div><div>$e1</div><div>[1] 10</div><div><br></div><div>attr(,"att1")</div>
<div>[1] 1</div><div>> </div><div>> src2 <- '</div><div>+ #include <Rcpp.h></div><div>+ // [[Rcpp::export]]</div><div>+ SEXP crtlist2() {</div><div>+   Rcpp::List lst;</div><div>+   lst["e1"] = 10;</div>
<div>+   lst.attr("att1") = 1;</div><div>+   lst["e2"] = 20;</div><div>+   return lst;</div><div>+ } </div><div>+ '</div><div>> sourceCpp(code = src2)</div><div>> crtlist2();</div><div>$e1</div>
<div>[1] 10</div><div><br></div><div>$e2</div><div>[1] 20</div><div><br></div><div>> </div></div><div><br></div><div>Note in the above, the printout for the second does not print any attribute as for the first function. </div>
<div><br></div><div>--</div><div>Jiqiang </div>