From jmc@research.bell-labs.com  Tue May 28 19:14:53 2002
From: jmc@research.bell-labs.com (John Chambers)
Date: Tue, 28 May 2002 14:14:53 -0400
Subject: signature match in setMethod (PR#1592)
References: <200205222104.XAA19333@pubhealth.ku.dk>
Message-ID: <3CF3C91D.C71FFE4A@research.bell-labs.com>

tkeitt@ms.cc.sunysb.edu wrote:
> 
> Full_Name: Tim Keitt
> Version: 1.5
> OS: Linux
> Submission from: (NULL) (128.227.201.237)
> 
> The function "setMethod" makes the following call to "insertMethod":
> 
> allMethods <- insertMethod(allMethods, signature, fnames[1:length(signature)],
>         asMethodDefinition(definition, signature))
> 
> If I understand insertMethod correctly, the third argument should be the names
> of the formal arguments of the method. However, this fails if the signature is
> something like "c('x', 'i', 'j', 'drop')" and the formal args are "c('x', 'i',
> 'j', '...', 'drop')" because the "..." gets passed instead of "drop". 

Not quite:  "..." gets passed (with class "ANY") in addition to "drop",
and insertMethod then generates an error, because it refuses to handle
"..."

> Changing
> this to
> 
> allMethods <- insertMethod(allMethods, signature, fnames[match(signature,
> fnames)],
>         asMethodDefinition(definition, signature))
> 
> seems to solve the problem.

Not quite.  The signature has already been processed at this point, so
match() isn't needed, but we do need to remove "..." from fnames and the
corresponding "ANY" from signature.  Also, the "..." isn't used for
dispatch, but it is needed to honor conforming methods that replace
"..." with specific arguments (a feature added to the API recently), so
it must be retained for comparing arguments of the generic and the
method definition.

There is a version committed to r-patched that should fix the problem.

> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

-- 
John M. Chambers                  jmc@bell-labs.com
Bell Labs, Lucent Technologies    office: (908)582-2681
700 Mountain Avenue, Room 2C-282  fax:    (908)582-3340
Murray Hill, NJ  07974            web: http://www.cs.bell-labs.com/~jmc
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


signature match in setMethod (PR#1592)
John Chambers