From jmc at r-project.org  Wed Mar 18 01:59:49 2009
From: jmc at r-project.org (John Chambers)
Date: Tue, 17 Mar 2009 17:59:49 -0700
Subject: [Rd] exporting s3 and s4 methods
In-Reply-To: <Pine.LNX.4.43.0903171015560.1676@hymn13.u.washington.edu>
References: <Pine.LNX.4.43.0903171015560.1676@hymn13.u.washington.edu>
Message-ID: <49C04785.80406@r-project.org>

Thomas Lumley wrote:
> On Tue, 17 Mar 2009, John Chambers wrote:
>
>> It's important though to use the default, one argument, call to 
>> setGeneric(). Otherwise the two functions are not consistent and 
>> can't exist in the same namespace.
>
> Thanks. Does this include restricting which arguments are used for 
> dispatch? I have
> setGeneric("bigglm", signature=c("formula","data"))
> to dispatch just on the first two arguments.
That seems not to disturb anything. (It's really only the arguments 
affecting the default that would break things directly. The other 
non-defaults are a problem if multiple packages turn the same S3 
function into a generic in inconsistent ways. But here you own both the 
S3 and S4 versions.)

(R2.8.1)> foo <- function(x,y,z)UseMethod("foo")
(R2.8.1)> setGeneric("foo", signature = c("x", "y"))
[1] "foo"
(R2.8.1)> getMethod(foo) # the default
Method Definition (Class ?derivedDefaultMethod?):

function (x, y, z)
UseMethod("foo")

Signatures:

target
defined
(R2.8.1)> foo at signature
[1] "x" "y"

> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] exporting s3 and s4 methods
John Chambers