[Rd] Another NAMESPACE question, imports and S4

Seth Falcon sfalcon at fhcrc.org
Wed Feb 8 21:05:35 CET 2006


One more namespaces thread and then I will be quiet for a while ;-)

Should S4 methods be attached to the appropriate generic when a
package is loaded, but not attached?

For example, suppose package 'hello' defines an S4 class Speaker and a
defines a method for the show generic defined in the methods package.
Then package 'goodbye' imports hello and defines a function that
creates a Speaker instance and calls show on it.  

The only way I've found thus far to get the show method defined in
'hello' to get attached to the generic is to exportMethods("show")
from 'goodbye'.  But I don't think I should have to export in order to
import.

I've posted packages hello and goodbye here:
http://bioconductor.fhcrc.org/developers/examples/

To see an example, install both then do:

    > library(goodbye)
    > goodbye()
    An object of class "Speaker"
    Slot "words":
    [1] "Goodbye, world"   

Thanks,

+ seth



More information about the R-devel mailing list