[Rd] S4 setMethod, setGeneric and default arguments

From: evilphil <phil.joubert_at_landg.com>
Date: Thu, 11 Nov 2010 04:13:51 -0800 (PST)

Hi Guys

I have defined a generic function, for which one of the arguments has a default:

setGeneric( "getFwdRate",

              function(.Object, tenorFrom, tenorTo=tenorFrom) standardGeneric("getFwdRate")

)

Then I have defined a method which also has a default:

setMethod( "getFwdRate", signature(.Object="CCurveVector", tenorFrom="numeric", tenorTo="numeric"),

              function(.Object, tenorFrom, tenorTo=tenorFrom+1) {
	[REMOVED IRRELEVANT IMPLEMENTATION
                      }

)

However, if I call

getFwdRate(thisYC, 1)

I get "Error in function (classes, fdef, mtable) : unable to find an inherited method for function "getFwdRate", for signature "CCurveVector", "numeric", "missing" "

Is there a way that this call would match the method I've defined? Or do I need to declare a duplicate method with signature(.Object="CCurveVector", tenorFrom="numeric", tenorTo="missing")? In which case what is the point of having default arguments in the method declaration?

thanks
Phil

-- 
View this message in context: http://r.789695.n4.nabble.com/S4-setMethod-setGeneric-and-default-arguments-tp3037716p3037716.html
Sent from the R devel mailing list archive at Nabble.com.

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Thu 11 Nov 2010 - 12:17:09 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 22 Nov 2010 - 12:50:25 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive