Re: [Rd] Specifying a function as not being and S3 Class function

From: S Ellison <S.Ellison_at_lgcgroup.com>
Date: Tue, 24 Apr 2012 17:50:15 +0100

> Is it possible to keep from triggering the following warning
> when I check the package?
>
> summary:
> function(object, ...)
> summary.agriculture:
> function(x, analyte.names, results.col, analyte.col, by, det.col,
> [clip]

Part of the solution is to add ... to the legacy function; that is required by the generic and is missing in your own function. Adding ... will not break existing code.

The name of the initial argument will still cause problems. But I've kludged round a similar issue (an intentional difference in required parameters, in my case) by replacing something like

obj.summary(x, y, z, ...)

with something like
obj.summary(object, y, z, x=object, ...)

This preserves legacy argument order, is consistent with summary(object, ...) and retains the named argument x to avoid code changes.

But it is clearly a kludge. It also runs the risk of accidental overwriting of x if someone specifies too many unnamed parameters. That should not happen in working legacy code, of course, as that would have broken if you included a surplus parameter in a function call with no ... . If it _is_ a problem you could try obj.summary(object, y, z, ..., x=object), which would avoid the accidental assignment by requiring exact match naming, but I cannot recall offhand if that construct would be considered consistent with the generic using the current CMD check.

Steve Ellison

> -----Original Message-----
> From: r-devel-bounces_at_r-project.org
> [mailto:r-devel-bounces_at_r-project.org] On Behalf Of Matt Pocernich
> Sent: 24 April 2012 16:34
> To: r-devel_at_r-project.org
> Subject: [Rd] Specifying a function as not being and S3 Class function
>
>
> I am compiling a library with legacy code which has functions
> named with periods in the names - but are not S3 class
> functions. For example for example, summary.agriculture
> is not an extension of the summary function for and
> 'agriculture. class object - it is just poorly named.
>
> Is it possible to keep from triggering the following warning
> when I check the package?
>
> * checking S3 generic/method consistency ... WARNING
>
> summary:
> function(object, ...)
> summary.agriculture:
> function(x, analyte.names, results.col, analyte.col, by, det.col,
> iQuantiles, iDetStats, iSW, iUCL, iLand, conf.level, iUTL,
> tol.level, utl.conf.level, iND, sig.figs)
>
> I know that the best answer would be to rename with a better
> naming convention, but that would cause issues with legacy
> applications.
>
> Thanks,
>
> Matt
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> *******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue 24 Apr 2012 - 16:52:24 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

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 Tue 24 Apr 2012 - 17:30:48 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