Making "S4" Classes and Methods Work with Namespaces

Some notes on changes needed or desirable (and possible?) to integrate the current (1.7.1) implementation of classes and methods with package namespaces.

Classes

Other class-based utilities will need to be modified to also allow the appropriate version of a class to be used (e.g,. is() and as()). Details will be important, but the general picture seems similar to that for new(): provide the environment of the calling function as the default, but with the possibility that the class "name" will override in the call to getClass().

Methods and Generic Functions

Conceptually, the requirement is that each relevant namespace or global environment have a suitable version of a particular generic function, corresponding to the list of methods visible. The basic point seems to be the following. If f is a generic function and package P defines methods for f, then a call to f from a function in the package sees the methods in P (including whatever P imports). But if f is visible globally, then a call to f from the global environment sees only the methods that are exported from the currently attached packages. The methods in P may or not be exported. The current dispatch mechanism is quite close to this model, except for primitive functions. These are a problem, in that dispatch is done from C without any generic function being visible, so some additional mechanism is needed. Details:
Last modified: Fri Jul 18 14:28:10 EDT 2003