On 19 October 2012 at 01:19, Christian Gunning wrote: | > Anything you pass from R into your C++ routine should be considered | > read-only. It's typically a bad idea to do in-place updates of the R | > object you passed in as an argument. | | Really? I was under the impression that the ability of in-place | modification was a conscious design decision.
... of .Call() in the R API? After all, we are passing SEXP -- S Expression POINTERS -- around. So you always can. Maybe what Davor was trying to say was along the lines of Doug's "const &" recommendation for style to avoid surprises. | Be aware that you've stepped outside of the functional programming | paradigm, yes. | But read-only? From the C++ point of view, it's just memory. Fullt agreed. | That said, if you want safety (e.g. default R behaviour), use clone(). | Then you can modify to your heart's content. Yes, at the cost of creating a copy. Dirk -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel