[R-pkg-devel] S4 Methods and Ellipsis Formals

Dario Strbenac d@tr7320 @end|ng |rom un|@@ydney@edu@@u
Wed Nov 17 09:00:03 CET 2021


Good day,

I read in the documentation of SetMethod that "Roughly, if the generic has ... as one of its arguments, then the method may have extra formal arguments, which will be matched from the arguments matching ... in the call to f." I was hoping that ellipsis could be also part of a method because this explanation doesn't explicitly rule it out. What I am hoping to do is:

setGeneric("Example", function(x, ...) standardGeneric("Example"))
setMethod("Example", "numeric", function(x, y, ...) as.list(...))
Example(x = 1, y = 2, z = 3, a = 99) # Error in typeof(x) : argument "x" is missing, with no default

So, ellipsis can't be a formal of a method, but only in the generic? May this be clarified by the documentation?

--------------------------------------
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia


More information about the R-package-devel mailing list