[Rd] Problems ahead from misuse of DUP=FALSE in .C and .Fortran calls
Prof Brian Ripley
ripley at stats.ox.ac.uk
Mon Apr 9 11:20:47 CEST 2007
I have been looking into making as.double() and friends do less copying
(and they now do in R-devel). The problem is that people have been
writing code which assumes copying is guaranteed, so we decided not to put
any changes into 2.5.0.
All but one of the cases I have detected (RandomFields, cluster::diana and
stats::smooth, but there may be others that I have not) are due to the use
of DUP=FALSE. Now, there is a pretty strong warning against this on the
help page, but people still do it and some of you are relying on as.xxxx
making a new object which the compiled code then alters.
I think the message is clear: do not use DUP=FALSE unless you can prove
that alteration of arguments in your C/Fortran code never has a
side-effect. Watch out for what that side-effect might be: in one case it
is to change the parsed code in the loaded namespace which affects
subsequent uses of the function but the first example works correctly (and
few test suites try functions repeatedly).
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-devel
mailing list