[Rd] S4 Methods dispatch

John Chambers jmc at r-project.org
Wed Aug 30 19:01:22 CEST 2006


John Chambers wrote:
> A revision of r-devel 2.4.0 is being committed today with changes to 
> method and class management.
>
> The changes are internal but extensive.  All packages that use S4 
> methods and classes need to be reinstalled from source to use the new 
> version.
>   
A footnote on this. ALL packages need to be reinstalled--including 
stats4 in the R source.  Otherwise that package will fail when used in 
the tests.   I was bitten by this myself today.

Advice from members of r-core more expert in the innards, suggests that 
the best thing to do is
  make clean
in the directory where you are building R, if you have previously built 
R there, before making the new version of R.
> The main effects are to speed up method caching and dispatch, and to fix 
> some problems with selecting inherited methods.  The new design is also 
> cleaner, so we can experiment more easily in the future with changes for 
> efficiency or semantics.
>
> The change will mostly be noticeable in attaching packages with many 
> methods.  The CPU time for attaching package Matrix, for example, goes 
> down by about a factor of 7 compared to R 2.3.1, timed on a Mac G5.
>
> The other major change is that now _all_ inherited methods are examined 
> and one of the closest matches is chosen.  The old selection took the 
> first candidate found, so the current version is better defined, and 
> will also let us experiment with various tuning & strategies.
>
> There is a draft paper describing method selection at
>   http://developer.r-project.org/howMethodsWork.pdf
> (It's a document in progress, so go back in a few days for a revised 
> version.)
>
> If a package uses inheritance for method selection with multiple 
> arguments, there may well be changes in behavior.  We found examples in 
> both methods itself and in Matrix that needed attention.
>
> John
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>




More information about the R-devel mailing list