Skip to content
Prev 35637 / 63424 Next

calling setGeneric() twice (don't; documentation comments)

On Tue, 2010-01-19 at 12:55 -0800, Seth Falcon wrote:
I tried a test in R 2.7.1, and that is the behavior.  I think it would
be worthwhile to document it in ?setGeneric.

Also, ?setGeneric advocates first defining a regular function (e.g.,
bar) and then doing a simple setGeneric("bar").  I think the advice for
package developers is different, so perhaps some changes there would be
a good idea too.

I thought I was defining setGeneric twice for a few functions, and thus
that it did work OK.  It turns out I have no duplicate definitions.

Here's the test:
[1] "A"
[1] "B"
[1] "foo"
[1] "foo"
[1] "foo for A"
Error in function (classes, fdef, mtable)  : 
  unable to find an inherited method for function "foo", for signature "B"
[1] "foo"
[1] "foo"
[1] "foo"
[1] "foo"
# here's where the disappearance of the prior setMethod shows
Error in function (classes, fdef, mtable)  : 
  unable to find an inherited method for function "foo", for signature "A"
[1] "foo for B"

So I guess I am going to pull the setGeneric's out.
Ross