[Rd] (PR#7320) Internal function isUME() in findGeneric() is wrong
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Oct 28 23:48:48 CEST 2004
The issue is the use of UseMethod(), which you claim to be valid. As it
is inconsistent with the prime documentation, the help page, I would
question if it is `perfectly legal'. I expect the author of isUME
implemented the behaviour described on the help page.
It is documented in S-PLUS as *strongly discouraged*, and although it is
documented in R-lang, I believe the right thing to do is to make the code
agree with the prime documentation.
I see no uses of UseMethod() in the R sources, and on CRAN only
one in a comment (and none in BioC).
On Thu, 28 Oct 2004 jhallman at frb.gov wrote:
> Full_Name: Jeff Hallman
> Version: 2.0
> OS: Linux
> Submission from: (NULL) (132.200.32.34)
>
>
> The function findGeneric() in the utils namespace contains this internal
> function:
>
> isUME <- function(e) {
> if (is.call(e) && (is.name(e[[1]]) || is.character(e[[1]]))) {
> switch(as.character(e[[1]]), UseMethod = as.character(e[[2]]),
> "{" = isUMEbrace(e), "if" = isUMEif(e), "")
> }
> else ""
> }
>
> This fails if the generic called UseMethod() without an argument, which is
> perfectly legal. Changing it to this seems to work:
>
> isUME <- function(e) {
> if(is.call(e) &&(is.name(e[[1]]) || is.character(e[[1]]))) {
> switch(as.character(e[[1]]),
> UseMethod = ifelse(length(e) == 1, fname, as.character(e[[2]])),
> "{" = isUMEbrace(e),
> "if" = isUMEif(e),
> "")
> }
> else ""
> }
>
>
> Jeff
>
> ______________________________________________
> R-devel at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-devel
mailing list