[Bioc-devel] BiocGenerics / NAMESPACE question

Kasper Daniel Hansen kasperdanielhansen at gmail.com
Mon Dec 5 20:36:25 CET 2011


2011/12/5 Hervé Pagès <hpages at fhcrc.org>:
> Hi Kapser,
>
>
> On 11-12-04 10:40 AM, Kasper Daniel Hansen wrote:
>>
>> I have looked a bit at BiocGenerics.  I may not be up to date on the
>> latest in export/NAMESPACE, but why are (almost) all the generics
>> exported as
>>
>>   export(lapply)
>>
>> and not
>>
>>   exportMethod(lapply)
>>
>> and why is combine/updateObject different.  Is it because you need
>> export() to register the generic and only exportMethod if the package
>> defines a method aside from the generic?
>
>
> Yep. export() is for a function (a generic is a function),
> exportMethod() is for a method. There is no "lapply" method defined
> in BiocGenerics, just the "lapply" generic function.
>
>
>> And does that mean I need to
>> treat exporting a method differently depending on whether or not the
>> package I am writing defines the generic or not?
>
>
> If the package you are writing defines a method for a generic that is
> defined elsewhere, then you need to import the generic and to export
> only the method. If your package defines the generic and at least one
> method for it, then you don't need to import anything (besides the
> method package of course) and you need to export the generic (with
> export()) and the method (with exportMethod()).

Thanks a lot, this is a clear explanation and it also makes sense.

However, I suspect that many packages do not follow this.  At least
Biobase does not, since it only uses exportMethods() without exporting
the generic separately for all the methods (like sampleNames,
phenoData etc).

Kasper



More information about the Bioc-devel mailing list