If a lean-and-mean version is needed for specialized use, there should be indeed a mechanism to run without whatever pieces are supposed to be inefficient.
However, the current treatment of S3 methods as internal and S4 methods as external perpetuates an inferior programming mechanism as the apparent standard, regardless of whether the user is concerned about startup time or not. Machine efficiency is important, but as I said in an earlier thread, it is not the purpose of statistical computing. Steps towards a solution may lie in activating S4 methods on demand (not requiring require()) and in storing active generic functions during a session in the package owning the original function (including base). The latter would remove dependencies on search list order by having only one version of the function. These are directions we can pursue for 2.5. Prof Brian Ripley wrote: > 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). > > Try > > gannet% cat > test.R > proc.time() > library(methods) > proc.time() > q() > 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. > > [[alternative HTML version deleted]] ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel