From jhallman at frb.gov  Thu Oct 28 17:01:31 2004
From: jhallman at frb.gov (jhallman@frb.gov)
Date: Thu Oct 28 17:01:34 2004
Subject: [Rd] Internal function isUME() in findGeneric() is wrong (PR#7320)
Message-ID: <20041028150131.073BE11350@slim.kubism.ku.dk>

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


[Rd] Internal function isUME() in findGeneric() is wrong (PR#7320)
jhallman@frb.gov