> There can't really be an "ImportGenerics", because S3 is so informal.  A 
> generic function is a function that calls UseMethod, but it can do anything 
> else as well.  So R would need some fancy code analysis to know whether it 
> was safe to import the generic but not all the dependencies of that package, 
> and that could change when the package holding the generic was updated.
> Examples of generics that do more than simply call UseMethod are rare, but 
> they exist:  as.data.frame() and sort() are a couple.
> Duncan Murdoch

Right -- ImportGenerics was a dumb idea. However, Something like ImportNoDeps 
makes sense as an additional category in the DESCRIPTION file. In my example, 
if such existed, I could put in the DESCRIPTION file:

    ImportNoDeps: multcomp

This would signal that multcomp -- but not necessarily any of its dependencies 
-- is required to install emmeans.  And in the NAMESPACE file:

    importFrom(multcomp, cld)
    S3method(cld, emmGrid)

... would import the needed generic and register my new S3 method.

I think this kind of construct could significantly reduce dependencies for 
packages that extend other packages' methods.

R-package-devel@r-project.org mailing list

Reply via email to