Skip to content
Back to formatted view

Raw Message

Message-ID: <DM6PR04MB438001A49FD769AAC54982A1F1D10@DM6PR04MB4380.namprd04.prod.outlook.com>
Date: 2019-08-10T19:27:17Z
From: Lenth, Russell V
Subject: [R-pkg-devel]  [External] Re: Farming out methods to other packages
In-Reply-To: <CALEXWq0urMLWJc+tD9pp=wRPFF2GPphfXSOfTBRjo_dy7jsd9g@mail.gmail.com>

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