[R] "privileged slots",

Roger Bivand Roger.Bivand at nhh.no
Tue Jun 1 12:26:43 CEST 2004


On 1 Jun 2004, Jari Oksanen wrote:

> On Tue, 2004-06-01 at 12:21, Torsten Steuernagel wrote:
> > On 28 May 2004 at 8:19, Duncan Murdoch wrote:
> > 
> > > I'd advise against doing this kind of optimization.  It will make your
> > > code harder to maintain, and while it might be faster today, if "@<-"
> > > is really a major time sink, it's an obvious candidate for
> > > optimization in R, e.g. by making it .Internal or .Primitive.  When
> > > that happens, your "optimized" code will likely be slower (if it even
> > > works at all).
> > 
> > Agreed. I don't recommend doing this either. I don't believe it makes 
> > any difference using "slot<-" instead of "@<-" in real life. Anyway, that 
> > "optimized" code should always work (slower or not) because "slot<-" 
> > is fully documented and I don't see why it should be removed or its 
> > behaviour should change. That wouldn't only break the kind of code 
> > mentioned here but also everything else that makes use of "slot<-".
> > 
> There are several other things that were fully documented and still were
> removed. One of the latest cases was print.coefmat which was abruptly
> made Defunct without warning or grace period: code written for 1.8*
> didn't work in 1.9.0 and if corrected for 1.9.0 it wouldn't work in
> pre-1.9.0. Anything can change in R without warning, and your code may
> be broken anytime. Just be prepared.

And the tools to stay prepared are there too - if your packages are on
CRAN, they get checked against patched and devel for free and the outcome
listed; if not on CRAN, you can always check them on devel locally too.  
Watching the notes on developer.r-project.org helps - the
print.coefmat change was highlighted for some time before 1.8.0 on:

http://developer.r-project.org/180update.txt

It is true, though, that writing current packages to be 
backwards-compatible to earlier R versions is extra overhead, and some 
users may not be able to change versions even if they'd like to. Using the 
appropriate methods is typically going to be more future-proof anyway (as 
a different thread noted recently in connection with namespaces).

> 
> cheers, jari oksanen 
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no




More information about the R-help mailing list