Re: [Rd] S4 generics, modify() generic and modifyList() ...

From: Prof Brian Ripley <>
Date: Thu 21 Sep 2006 - 08:34:07 GMT

On Thu, 21 Sep 2006, Martin Maechler wrote:


> For the mid to longer term I agree a modify() generic might be
> nicer, and the method for "function" may even be more useful
> than the one for list [[and modifyList() would eventually be deprecated]].
> OTOH, for new generics, I'd tend to argue we should be nice R-izens
> and use S4 rather than S3. For the time being that
> would mean it had to go into the methods package.
> Or is now {with the dramatic S4 improvements in 2.4.0} a good
> time to start thinking about making "utils" depend on "methods"
> or even "better" [ ;-) I know, not all agree here ]
> think about a dependency tree
> base -> methods -> [everything else] for the base packages ?
> so we could merge 'stats4' into 'stats' ?

Please no: that would have a 'dramatic' effect on startup times for the 'lean and mean' R used as a scripting engine when building R (that often uses utils).


gannet% cat > test.R
gannet% env R_DEFAULT_PACKAGES='utils' Rbeta --slave < test.R [1] 0.124 0.016 0.125 0.000 0.000
[1] 0.632 0.040 0.657 0.000 0.000

so methods would increase the startup time ca 5x. There has been no discernable progress on the cost of startup of methods when there are no S4 generics in the other packages: it is slower than all the other default packages put together. Similarly, there is a considerable cost to S3 dispatch of having an S4 take-over of S3 generics (especially internal generics).

Good 'R-izens' need to consider the environmental impact of their use of S4 code. One thing we may be getting closer to is not making 'methods' a default package at all, but loading it only when needed. (Now S4 objects can be identified easliy, that could be checked when one is created/loaded.) It is like the on-going debate on 4x4 vehicles (SUVs to Americans), which carry a lot of extra weight for off-road features that are almost never used.

Brian D. Ripley,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ mailing list
Received on Thu Sep 21 18:53:04 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 21 Sep 2006 - 14:30:08 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.