[Rd] calling setGeneric() twice
Seth Falcon
seth at userprimary.net
Tue Jan 19 21:55:15 CET 2010
On 1/19/10 11:19 AM, Ross Boylan wrote:
> If files that were read in later in the sequence extended an existing
> generic, I omitted the setGeneric().
>
> I had to resequence the order in which the files were read to avoid some
> "undefined slot classes" warnings. The resequencing created other
> problems, including some cases in which I had a setMethod without a
> previous setGeneric.
>
> I have seen the advice to sequence the files so that class definitions,
> then generic definitions, and finally function and method definitions
> occur. I am trying not to do that for two reasons. First, I'm trying
> to keep the changes I make small to avoid introducing errors. Second, I
> prefer to keep all the code related to a single class in a single file.
If at first you do not get the advice you want, ask again! :-)
Perhaps you could do something like:
if (!isGeneric("blah")) { setGeneric("blah", ...) }
I would expect setGeneric to create a new generic function and nuke/mask
methods associated with the generic that it replaces.
> Some of the files were intended for free-standing use, and so it would
> be useful if they could retain setGeneric()'s even if I also need an
> earlier setGeneric to make the whole package work.
>
> I am also working on a python script to extract all the generic function
> defintions (that is, setGeneric()), just in case.
Perhaps another option is to group all of the generics together into a
package and reuse that? Unless you are using valueClass, I don't think
you will need any class definitions.
+ seth
More information about the R-devel
mailing list