From pgilbert at bank-banque-canada.ca  Mon Mar 21 18:59:30 2005
From: pgilbert at bank-banque-canada.ca (Paul Gilbert)
Date: Mon Mar 21 19:01:36 2005
Subject: [Rd] loadings generic?
In-Reply-To: <16959.2316.560057.121298@stat.math.ethz.ch>
References: <423D98B9.7050005@bank-banque-canada.ca>
	<16959.2316.560057.121298@stat.math.ethz.ch>
Message-ID: <423F0B82.9080802@bank-banque-canada.ca>



Martin Maechler wrote:

>>>>>>"PaulG" == Paul Gilbert <pgilbert@bank-banque-canada.ca>
>>>>>>    on Sun, 20 Mar 2005 10:37:29 -0500 writes:
>>>>>>            
>>>>>>
>
>    PaulG> Can loadings in stats be made generic?
>
>It becomes a (S4) generic automagically when you define an S4 method
>for it.  ;-)
>
>{yes, I know this isn't the answer you wanted to hear;
> but really, maybe it's worth considering to use S4 classes and
> methods ?}
>  
>
Yes, sometime.

>For S3, it's a bit uglier, but I think you could still do -- in your
>package --
>
>if(!exists("loadings.default", mode="function")) {
>  loadings.default <- loadings
>  loadings <- function(x, ...) UseMethod("loadings")
>}
>
>loadings.<myclass> <- function(x, ...) {
>   ......... 
>}
>
>and S3-export these.
>
I am doing this, but expect others will want to do it too. I think it 
gets a bit messy when multiple packages need to define the same generic. 
At least, it seems to me it would make more sense for the generic to be 
defined in one place that everyone uses.

Paul

>
>Martin
>
>  
>


[Rd] loadings generic?
Paul Gilbert