[Rd] Utilities for methods

John Chambers jmc at r-project.org
Tue Mar 18 17:51:36 CET 2008


The first implementation of the methods package used the  "MethodsList" 
class for method dispatch.  Objects from the class stored methods 
recursively by the separate arguments in the method signature.

That was a good structure for selecting a method, but not for most other 
utilities.  However, it was used for essentially everything in the 
beginning.  The methods list for a particular function in a particular 
package was stored in an object in the package's namespace or 
environment, under a mangled name.

For some time now this class has been replaced for method selection by 
environment tables that store methods by a string derived from the 
signature.  The tables provide faster and more flexible computations.  
These tables are now stored and used instead of methods lists, but we 
continue to compute and assign the old objects as well.

The time has come to get rid of the old objects, since there is some 
overhead in computing them and they can cause confusion or errors.

The first step, for 2.7.0, will be to introduce some new utilities that 
return simpler structures---additions, not replacements for any current 
utilities.  At the same time, we will deprecate the function that 
returns the mangled name for the old metadata objects---I very much hope 
no one is currently using this outside of the R code itself, in any case.

For this round, the old metadata objects will still be generated.  It's 
likely they will disappear in version 2.8.  Meanwhile, the R code itself 
will be modified to not use these objects for standard utilities.

With luck, the new code will be committed to r-devel within a few days.  
It should not cause any visible change except for those really digging 
into the innards, and not too likely even then.   If you have functions 
that manipulate MethodsList objects (e.g.,  from calling getMethods()), 
these should still work.  But you might consider changing to newer 
utilities that should be faster and more convenient, at least when more 
than one argument is involved.

The new utilities will be:  findMethods(), which returns a simple list 
of methods (replacement for getMethods()); findMethodSignatures(), which 
returns a character matrix of signatures; and hasMethods(), which tests 
for the existence of methods.

Cheers,
John



More information about the R-devel mailing list