From seth at userprimary.net  Tue Jan 19 21:55:15 2010
From: seth at userprimary.net (Seth Falcon)
Date: Tue, 19 Jan 2010 12:55:15 -0800
Subject: [Rd] calling setGeneric() twice
In-Reply-To: <1263928770.10417.52.camel@corn.betterworld.us>
References: <1263924060.10417.31.camel@corn.betterworld.us>	
	<4B55F45C.4040408@userprimary.net>
	<1263928770.10417.52.camel@corn.betterworld.us>
Message-ID: <4B561C33.8080901@userprimary.net>

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



[Rd] calling setGeneric() twice
Seth Falcon