[R-pkg-devel] [External] Re: Two packages with the same generic function
Yes, but I think my concern may have been bogus. WRE says that even though the whole package is loaded, it is *not* placed on the search path. Only exports from the package go on the search path. So if the imported generic is not then explicitly exported, it would not be seen nor cause a conflict with another generic of the same name that is exported. At least that's my understanding. However, this discussion is getting too esoteric for me, so I'm just going to shut up and leave it to folks who are more knowledgeable. With apologies for my noise. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Jun 23, 2020 at 7:29 AM Viechtbauer, Wolfgang (SP) <
wolfgang.viechtbauer at maastrichtuniversity.nl> wrote:
Still, if pkgA imports the generic from pkgB, then installing pkgA
installs pkgB and all of its dependencies (Depends and Imports). Which of
course makes sense (as otherwise pkgB cannot be installed). But all of this
just for importing
foo <- function(x, ...)
UseMethod("foo")
from pkgB.
Best,
Wolfgang
-----Original Message----- From: R-package-devel [mailto:r-package-devel-bounces at r-project.org] On Behalf Of Duncan Murdoch Sent: Tuesday, 23 June, 2020 12:25 To: Guido Schwarzer; r-package-devel at r-project.org Subject: Re: [R-pkg-devel] [External] Re: Two packages with the same
generic
function On 23/06/2020 4:22 a.m., Guido Schwarzer wrote:
Am 23.06.20 um 10:00 schrieb Viechtbauer, Wolfgang (SP):
[...] @Neal: A separate package with generic functions that pkgA and pkgB
could
import is an interesting suggestion, thanks!
What makes this interesting is that there is no dependency on other packages in generics. Remains the question which help page would be shown for help(foo).
If a package imports and then exports the generic, it would normally create a help page referring to the original one where the generic is defined. So both pkgA and pkgB would probably both create help pages, and the help system would show a page listing them both plus the generic one, and asking the user to choose. An example happens if you use library(broom) ?tidy The broom package links to a page that says "These objects are imported from other packages. Follow the links below to see their documentation." One of the links is to the ?tidy page in the generics package. You are allowed to say ?broom::tidy, and then you don't go to the list of possibilities, you go directly to the one you asked for. Duncan Murdoch
______________________________________________ R-package-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel