There seems to be an issue with passing "..." to callGeneric(),
because it
assumes that the call can be evaluated in the parent frame. Due to lazy
evaluation, that is often not going to work for arguments that are simply
passed down via "...".
Here is an example:
setClass("A", contains = "character")
setClass("B", contains = "character")
setGeneric("fun", function(x, ...) standardGeneric("fun"))
setMethod("fun", "A", function(x, ...) {
callGeneric(new("B"), ...)
})
setMethod("fun", "B", function(x, ..., arg) {
arg
})
fun2 <- function() {
arg <- 0
fun(new("A"), arg = arg)
}
> fun2()
Error in .local(x, ...) : object 'arg' not found
Replacing the "callGeneric" with "fun" in the above leads to
the expected
result:> fun2()
[1] 0
In callGeneric, we have:
call <- substitute(fname(...))
eval(call, sys.frame(sys.parent()))
If this is changed to:
do.call(f, list(...))
then everything works as expected.
Michael
[[alternative HTML version deleted]]