[R] .C and DUP=TRUE versus .Call

Jonathan Rougier J.C.Rougier at durham.ac.uk
Thu Sep 7 15:56:39 CEST 2000


Hi Brian,

On Thu, 7 Sep 2000, Prof Brian Ripley wrote:

> .C with DUP=TRUE (the default) copies the objects on the way in and on
> the way out.  Incidentally, the first argument against DUP=FALSE,
> 
>      There are three important dangers with `DUP=FALSE'. The first is
>      that garbage collection may move the object, resulting in the
>      pointers pointing nowhere useful and causing hard-to-reproduce
>      bugs.
> 
> is no longer true in the development version, which has a non-moving
> garbage collector.

That sounds interesting -- it was only the first argument I was worried
about.

> If your code does not modify any of the arguments, how does it do anything
> useful?  Non-R side-effects like printing?

It wasn't strictly true.  The only thing it modifies is an object that is
created to hold the returning value.

> The short answer is that I would use .Call for things like this.
> However, if I had a .C version only if I found it necessary.  The
> experience with Svr4 (which is cleverer at not copying and allows
> selective copying of .C arguments) is that the copying is rarely
> expensive enough to think about compared to doing things to large objects.
> (The development version can increase workspace for a temporary
> copy as required.)

Unfortunately these are really large objects where one extra copy can make
a big difference.  In fact, we'd use larger objects yet if we could but we
cannot fit them into R.  Thanks for your help,

Jonathan.

Jonathan Rougier                       Science Laboratories
Department of Mathematical Sciences    South Road
University of Durham                   Durham DH1 3LE
http://www.maths.dur.ac.uk/stats/people/jcr/jcr.html

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list