Re: [R-pkg-devel] Two packages with the same generic function

2020-06-23 Thread Duncan Murdoch
On 22/06/2020 10:17 p.m., Bert Gunter wrote: "Users don't get warned about overriding names in packages they've loaded, because that would just be irritating." Is that also true if the package or generic is imported by another that they load; or is a dependency of a package they load? If so, I

Re: [R-pkg-devel] Two packages with the same generic function

2020-06-22 Thread Bert Gunter
"Users don't get warned about overriding names in packages they've loaded, because that would just be irritating." Is that also true if the package or generic is imported by another that they load; or is a dependency of a package they load? If so, I would not call it "just irritating" because if

Re: [R-pkg-devel] Two packages with the same generic function

2020-06-22 Thread Mark Leeds
Hi Duncan: I maintain dynlm and your example is the exact reason I've been getting emails from people regarding it not working correctly. I've been telling them to load dplyr by using library(dplyr, exclude = c("filter", "lag")) On Mon, Jun 22, 2020 at 7:57 PM Duncan Murdoch wrote: > On

Re: [R-pkg-devel] Two packages with the same generic function

2020-06-22 Thread Duncan Murdoch
On 22/06/2020 3:48 p.m., Tom Wainwright wrote: Yet another alternative is simply to prevent your second package from overriding the previously defined generic. The basic problem is the ease with which R allows overriding prior generic definitions (one of those bits of bad behavior we in the USA

Re: [R-pkg-devel] Two packages with the same generic function

2020-06-22 Thread Tom Wainwright
Yet another alternative is simply to prevent your second package from overriding the previously defined generic. The basic problem is the ease with which R allows overriding prior generic definitions (one of those bits of bad behavior we in the USA used to call "a Bozo No-No"), which hides all the

Re: [R-pkg-devel] Two packages with the same generic function

2020-06-22 Thread Neal Fultz
Another decent alternative is to submit the generic function to the `generics` package - https://github.com/r-lib/generics - or create your own API package. Both package A and B can import the generic from it, and everything works fine. It may also reduce your dependencies and/or build time.

Re: [R-pkg-devel] Two packages with the same generic function

2020-06-22 Thread Duncan Murdoch
On 22/06/2020 1:40 p.m., Bert Gunter wrote: ... and just to add to the query, assume the author of pkg B did (does) not know of pkg A and so, for example, could (did) not import any of pkg A's content into B. Given that there are at the moment ~20,000 packages out there, this does not seem to be

Re: [R-pkg-devel] Two packages with the same generic function

2020-06-22 Thread Bert Gunter
... and just to add to the query, assume the author of pkg B did (does) not know of pkg A and so, for example, could (did) not import any of pkg A's content into B. Given that there are at the moment ~20,000 packages out there, this does not seem to be an unreasonable assumption. One may even

[R-pkg-devel] Two packages with the same generic function

2020-06-22 Thread Viechtbauer, Wolfgang (SP)
Hi All, Let's say there are two packages pkgA and pkgB, both of which have a generic function foo <- function(x, ...) UseMethod("foo") and pkgA has a method for objects of class "A": foo.A <- function(x, ...) print(x) and pkgB has a method for objects of class "B": foo.B <-