Re: [Rd] calling setGeneric() twice

From: Seth Falcon <>
Date: Tue, 19 Jan 2010 12:55:15 -0800

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 mailing list Received on Tue 19 Jan 2010 - 21:00:24 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 20 Jan 2010 - 12:40:14 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive