[Rd] Should dots be used in generic functions?

Duncan Murdoch murdoch@stats.uwo.ca
Fri, 18 Jan 2002 11:11:34 -0500


On Fri, 18 Jan 2002 14:07:39 +0000 (GMT), you wrote in message
<Pine.LNX.4.31.0201181402540.25216-100000@gannet.stats>:

>On Fri, 18 Jan 2002, Duncan Murdoch wrote:
>
>> When writing generic functions, should "..." arguments be routinely
>> used?
>>
>> The Writing R Extensions manual says that if it is used, all
>> descendant methods must use it too.  In most cases in the R library
>> source, the generic has the dots, often documented as parameters for
>> the descendants (e.g. profile does this).  In the case of profile, the
>> descendants declare the dots, but don't make use of them.
>
>You mean the `methods' (they are not really descendants of anything)?  If
>so, you can't tell, as anyone can write a method.  In this case there are
>methods profile.nls and profile.glm, and they each have arguments that the
>generic and the other method does not have, so they do make use of the ...
>in the generic.

I was stupid, I didn't realize that if you don't have ... in the
generic, then you can't use the generic to call methods with new
parameters.

This is way too late to be changed in the old objects, but I'd suggest
a change in the new system, so that there is a way to detect errors in
the parameters used when calling a method.  Right now, if the
Extensions manual advice is followed, the only way to do that is to
add an explicit test at the start of the method:

if(length(list(...))) stop('args not matched')

Duncan



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._