From hpages at fhcrc.org  Sat Oct 26 03:05:51 2013
From: hpages at fhcrc.org (=?windows-1252?Q?Herv=E9_Pag=E8s?=)
Date: Fri, 25 Oct 2013 18:05:51 -0700
Subject: [Rd] advise on Depends
In-Reply-To: <CAOQ5Nyf=OtctzAgkTFL17w74++xzSgbBHB=p5WkAuxbsq7sO1w@mail.gmail.com>
References: <CAC2h7usRKfUJpwq+hvgGmb_fQ4NhzQxhK1ynvWHQkjf8kw5Zbg@mail.gmail.com>
	<CAOQ5Nyf=OtctzAgkTFL17w74++xzSgbBHB=p5WkAuxbsq7sO1w@mail.gmail.com>
Message-ID: <526B156F.7000502@fhcrc.org>

On 10/25/2013 11:26 AM, Michael Lawrence wrote:
> On Wed, Oct 23, 2013 at 8:33 PM, Kasper Daniel Hansen <
> kasperdanielhansen at gmail.com> wrote:
>
>> This is about the new note
>>
>> Depends: includes the non-default packages:
>>    ?BiocGenerics? ?Biobase? ?lattice? ?reshape? ?GenomicRanges?
>>    ?Biostrings? ?bumphunter?
>> Adding so many packages to the search path is excessive and importing
>> selectively is preferable.
>>
>> Let us say my package A either uses a class B (by producing an object that
>> has B embedded as a slot) from another package or provides a specific
>> method for a generic defined in another package (both examples using S4).
>>   In both case my impression is that best practices is I ought to Depend on
>> such a package, so it is a available at run time to the user.
>>
>>
> For classes, you just need to import the class with importClassesFrom().
> For generics, as long as your package exports the method with
> exportMethods(), the generic will also be exported from your package,
> regardless of whether the defining package is attached. And the methods
> from the loaded-but-not-attached packages are available for the generic. So
> neither of these two is really a problem.
>
> The rationale for Depends is that the user might always want to use
> functions defined by another package with objects consumed/produced by your
> package, such as generics for which your package has not defined any
> methods. For example, rtracklayer Depends on GenomicRanges, because it
> imports objects from files as GenomicRanges objects.  So just consider what
> the user sees when looking at your API. What's private, what's public?

And also the user should be able to use ? to access the full
documentation of what is public. This means that if your package
defines and exports a method for a generic defined elsewhere, it should
"Depends" on the package where the generic is defined. Same thing if
your package extends a class defined elsewhere.

Cheers,
H.

>
> Michael
>
>
>> Comments?
>>
>> Best,
>> Kasper
>>
>>          [[alternative HTML version deleted]]
>>
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>>
>
> 	[[alternative HTML version deleted]]
>
>
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Herv? Pag?s

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpages at fhcrc.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319



[Rd] advise on Depends
=?windows-1252?Q?Herv=E9_Pag=E8s?=