[R-pkg-devel] [External] Re: Farming out methods to other packages

Lenth, Russell V ru@@e||-|enth @end|ng |rom u|ow@@edu
Sat Aug 10 21:27:17 CEST 2019


Hmmmm, I thought of an approach -- a kind of manual dispatch technique. My generic is

recover_data <- function(object, ...) {
    rd <- try(getS3method("recover_data", class(object)[1], envir = .GlobalEnv, silent = TRUE))
    if (!inherits(rd, "try-error"))
        rd(object, ...)
    else
        UseMethod("recover_data")
}

and similar for emm_basis. The idea is it tries to find the method among globally registered ones, and if so, it uses it; otherwise, the internal one is used.

Comments? This does seem to add some overhead, but maybe not too unreasonably much.

Russ



More information about the R-package-devel mailing list