[Rcpp-devel] Forcing a shallow versus deep copy
JJ Allaire
jj.allaire at gmail.com
Fri Sep 13 14:00:13 CEST 2013
>
> Is it a big deal that we would cheat on chat reference passing means ?
>
If you want to implement these sort of semantics I think at a _minimum_ the
type should be const & (otherwise it looks like you are going to actually
modify the matrix in place which would appear to bypass the implicit memory
barrier of SEXP). Realize that you won't actually bypass the memory barrier
but it sure looks like you intend to for a reader of the code.
> Rcpp::RNGScope __rngScope;
> arma::mat& m = Rcpp::as<arma::mat& >(mSEXP);
> test_ref(m);
>
It looks like this behavior changed as of rev 4400 when the full_name()
method was introduced. I may not understand the mechanism you established
100% but to me this generated code looks potentially problematic if you are
taking a reference to a stack variable establish within the as<> method. My
guess is that you have something more sophisticated going on here and there
is no memory problem, however I'd love to understand things a bit better to
be 100% sure there isn't something to drill into further.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130913/9fa69c81/attachment.html>
More information about the Rcpp-devel
mailing list