RE: [R] Only referenc copy when calling C routine?

2004-04-12 Thread Thomas Lumley
On Sun, 11 Apr 2004, Shin, Daehyok wrote: > Thanks, Andy. > Let me ask a little more about the DUP argument. > In the manual, I can see that only reference copy happens when passing an > array, > if DUP=FALSE. Then, what happens when returning it in a list, if DUP=FALSE? > Another reference copy,

Re: [R] Only referenc copy when calling C routine?

2004-04-11 Thread Duncan Murdoch
On Sun, 11 Apr 2004 21:43:58 -0400, you wrote: >For me it's just a matter of getting my hands dirty, I guess. For whatever >reason I seem to have a mental block about the PROTECT/UNPROTECT business... Just protect every SEXP until you don't care if it goes away. It might be possible to skip som

RE: [R] Only referenc copy when calling C routine?

2004-04-11 Thread Shin, Daehyok
ROTECTED] > Sent: Sunday, April 11, 2004 PM 9:35 > To: Liaw, Andy > Cc: '[EMAIL PROTECTED]'; Liaw, Andy; R, Help > Subject: Re: [R] Only referenc copy when calling C routine? > > > On Sun, 11 Apr 2004 21:25:13 -0400, you wrote: > > >My understanding is that

RE: [R] Only referenc copy when calling C routine?

2004-04-11 Thread Liaw, Andy
For me it's just a matter of getting my hands dirty, I guess. For whatever reason I seem to have a mental block about the PROTECT/UNPROTECT business... Best, Andy > From: Duncan Murdoch [mailto:[EMAIL PROTECTED] > > On Sun, 11 Apr 2004 21:25:13 -0400, you wrote: > > >My understanding is that

Re: [R] Only referenc copy when calling C routine?

2004-04-11 Thread Duncan Murdoch
On Sun, 11 Apr 2004 21:25:13 -0400, you wrote: >My understanding is that if DUP=FALSE, no copying is done in either >direction. > >If you want to avoid copying, the .Call interface is probably more suitable, >as you pass the actual R objects to the C function. I'm not familiar with >that, though.

RE: [R] Only referenc copy when calling C routine?

2004-04-11 Thread Liaw, Andy
My understanding is that if DUP=FALSE, no copying is done in either direction. If you want to avoid copying, the .Call interface is probably more suitable, as you pass the actual R objects to the C function. I'm not familiar with that, though. Andy > From: Shin, Daehyok [mailto:[EMAIL PROTECTED

RE: [R] Only referenc copy when calling C routine?

2004-04-11 Thread Shin, Daehyok
Thanks, Andy. Let me ask a little more about the DUP argument. In the manual, I can see that only reference copy happens when passing an array, if DUP=FALSE. Then, what happens when returning it in a list, if DUP=FALSE? Another reference copy, or deep copy? I am trying to implement a dynamic model

RE: [R] Only referenc copy when calling C routine?

2004-04-11 Thread Liaw, Andy
I thought that description is rather clear. If `x' is a vector of doubles, then result <- .C("myCfunc", x = x) makes a copy of `x' to be passed to `myfunc'. The copy in R is not touched. When `myfunc' returns, another copy is made and placed into result[["x"]]. There's the `DUP' argument in .C