From hb at maths.lth.se  Thu Apr 21 21:32:49 2005
From: hb at maths.lth.se (Henrik Bengtsson)
Date: Thu Apr 21 21:33:03 2005
Subject: [Rd] Overloading methods in R
In-Reply-To: <Pine.SOL.4.20.0504211520200.24738-100000@santiam.dfci.harvard.edu>
Message-ID: <000701c546a8$e7d3e1c0$ab0040d5@hblaptop>

> -----Original Message-----
> From: r-devel-bounces@stat.math.ethz.ch 
> [mailto:r-devel-bounces@stat.math.ethz.ch] On Behalf Of Jeff Gentry
> Sent: Thursday, April 21, 2005 9:22 PM
> To: Ali -
> Cc: r-devel@stat.math.ethz.ch
> Subject: RE: [Rd] Overloading methods in R
> 
> 
> 
> On Thu, 21 Apr 2005, Ali - wrote:
> > I guess the context says you cannot have something like this in S4:
> > >setGeneric("testFun", function(...)
> > + standardGeneric("testFun"))
> 
> But what is wrong with:
> 
> setGeneric("testFun", function(object, ...))

Naming conflicts, may be the problem. You have that generic in your package,
but I might, without know about yours, and I write 

 setGeneric("testFun", function(x, ...))

in my package, and then a third person that we don't know of, is loading
both of our packages. Ouch! Indeed, this do happens. 

I would be ok with the above, if everyone agreed to use 'object' as the
first argument - but then you have plot(x, ...) and so on. Also, how should
you treat default functions not taking any arguments, e.g. traceback()?
Until then I stick with testFun <- function(...) UseMethod("foo") whenever
possible.

Cheers

Henrik
 
> Keeping in mind that 'object' is the actual instantiated 
> object of the class which you wish to operate on.  I guess I 
> don't see how that aspect is a problem?
> 
> ______________________________________________
> R-devel@stat.math.ethz.ch mailing list 
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
>


[Rd] Overloading methods in R
Henrik Bengtsson