Re: [Rcpp-devel] Problem passing Armadillo objects back to R

2011-04-07 Thread Romain Francois
Le 07/04/11 05:07, Christian Gunning a écrit : The issue is that when calling wrap it creates an unprotected SEXP, and Rcpp is not responsible for these. If the programmer passes an unprotected SEXP to ::create, it is his responsability to protect it. Just to clarify -- in the case of a naive u

Re: [Rcpp-devel] Problem passing Armadillo objects back to R

2011-04-06 Thread Günter J. Hitsch
Thank you, Romain. Looks like your simple workaround fixes all my problems. Günter On Apr 6, 2011, at 6:22 AM, Romain Francois wrote: > H. I'm afraid I can't fix this. > > Here is the story: both wrap(X) and wrap(X) create a new SEXP and allocate > memory. When wrap(Y) is called, s

Re: [Rcpp-devel] Problem passing Armadillo objects back to R

2011-04-06 Thread Christian Gunning
> The issue is that when calling wrap it creates an unprotected SEXP, and > Rcpp is not responsible for these. If the programmer passes an > unprotected SEXP to ::create, it is his responsability to protect it. Just to clarify -- in the case of a naive user who's not protecting objects: a single w

Re: [Rcpp-devel] Problem passing Armadillo objects back to R

2011-04-06 Thread Romain Francois
Le 06/04/11 17:12, Davor Cubranic a écrit : To make it harder for users to shoot themselves in the foot with 'List::create(Named("x") = wrap(X), ...', is it possible to make it simply illegal to assign an explicit "wrap" to a "Named"? This would force everyone to use implicit wraps, which as yo

Re: [Rcpp-devel] Problem passing Armadillo objects back to R

2011-04-06 Thread Davor Cubranic
To make it harder for users to shoot themselves in the foot with 'List::create(Named("x") = wrap(X), ...', is it possible to make it simply illegal to assign an explicit "wrap" to a "Named"? This would force everyone to use implicit wraps, which as you said are safe. Davor On 2011-04-06, at 4:

Re: [Rcpp-devel] Problem passing Armadillo objects back to R

2011-04-06 Thread Romain Francois
H. I'm afraid I can't fix this. Here is the story: both wrap(X) and wrap(X) create a new SEXP and allocate memory. When wrap(Y) is called, since the created object is large, R calls the GC to collect unprotected SEXP to free some space. So my guess is that at that point the SEXP that i

Re: [Rcpp-devel] Problem passing Armadillo objects back to R

2011-04-06 Thread Romain Francois
Good news. I can reproduce it. Bas news. This is likely a PROTECT problem with the Rcpp::List constructor. Wearing my bugbuster costume, and getting ready for a fight. Romain Le 07/03/11 23:03, "Günter J. Hitsch" a écrit : I'm new to Rcpp and RcppArmadillo---so far I like it a lot! Thanks to

Re: [Rcpp-devel] Problem passing Armadillo objects back to R

2011-03-07 Thread Dirk Eddelbuettel
On 8 March 2011 at 14:50, baptiste auguie wrote: | I get the same incorrect results as Günter for both the and | versions. Ack, thanks for the confirmation. Maybe Romain has a chance to take a look as I do not have a Mac handy. Dirk -- Dirk Eddelbuettel | [email protected] | http://dirk.edd

Re: [Rcpp-devel] Problem passing Armadillo objects back to R

2011-03-07 Thread baptiste auguie
Hi, I get the same incorrect results as Günter for both the and versions. Cheers, baptiste sessionInfo() R version 2.12.2 Patched (2011-03-02 r54645) Platform: i386-apple-darwin9.8.0/i386 (32-bit) locale: [1] C attached base packages: [1] stats graphics grDevices utils datasets gr

Re: [Rcpp-devel] Problem passing Armadillo objects back to R

2011-03-07 Thread Dirk Eddelbuettel
Hi Guenter, On 7 March 2011 at 16:03, "Günter J. Hitsch" wrote: | | I'm new to Rcpp and RcppArmadillo---so far I like it a lot! Thanks to the | developers for their good work. | | I run into a peculiar kind of problem when I try to pass a "large" Armadillo | object back to R. Here's some code

[Rcpp-devel] Problem passing Armadillo objects back to R

2011-03-07 Thread Günter J. Hitsch
I'm new to Rcpp and RcppArmadillo---so far I like it a lot! Thanks to the developers for their good work. I run into a peculiar kind of problem when I try to pass a "large" Armadillo object back to R. Here's some code to replicate the problem in stylized form: extern "C" SEXP testFun(SEXP L