From ross at biostat.ucsf.edu  Tue Jan 19 19:01:00 2010
From: ross at biostat.ucsf.edu (Ross Boylan)
Date: Tue, 19 Jan 2010 10:01:00 -0800
Subject: [Rd] calling setGeneric() twice
Message-ID: <1263924060.10417.31.camel@corn.betterworld.us>

Is it safe to call setGeneric twice, assuming some setMethod's for the
target function occur in between?  By "safe" I mean that all the
setMethod's remain in effect, and the 2nd call is, effectively, a no-op.

?setGeneric says nothing explicit about this behavior that I can see.
It does say that if there is an existing implicity generic function it
will be (re?)used. I also tried ?Methods, google and the mailing list
archives.

I looked at the code for setGeneric, but I'm not confident how it
behaves.  It doesn't seem to do a simple return of the existing value if
a generic already exists, although it does have special handling for
that case.  The other problem with looking at the code--or running
tests--is that they only show the current behavior, which might change
later.

This came up because of some issues with the sequencing of code in my
package.  Adding duplicate setGeneric's seems like the smallest, and
therefore safest, change if the duplication is not a problem.

Thanks.
Ross Boylan



[Rd] calling setGeneric() twice
Ross Boylan