Hi Josh, On 7 July 2012 at 17:05, Joshua Wiley wrote: | Thank you so much! That worked and helped me understand why it was | happening :) The idea of pointers is new to me so I think I need to | spend more time learning about that.
You can think of the Rcpp::* objects as 'proxies' for the R objects. That is a good thing: imagine a humongous R object---now we don't have to copy it, but just a pointer to it --> much quicker and efficient. Downside: we're pointed to the original. The issue has come up here repeatedly in the past; the first time lead to a longer thread. It also just came up again on SO a few days ago: http://stackoverflow.com/questions/11300048/rcpp-pass-by-reference-vs-by-value/ I have an even more confusing example in the workshop slides: if you use a NumericVector but then pass an int vector __Rcpp now has to do a deep copy for you__ as we cannot pass the C++ representation of an int vector to a float vector so in that case it wouldn't modify your original input either. Cheers, Dirk -- Dirk Eddelbuettel | [email protected] | http://dirk.eddelbuettel.com _______________________________________________ Rcpp-devel mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
