Simplify maintenance of NSE-SE pairs. Hypothetical dplyr
example:
#' @export
#' @keywords internal
mutate_ <- function (.data, ..., .dots) { UseMethod("mutate_") }
#' @export
#' @name mutate
mutate <- lazyforward::lazyforward("mutate_")
The result:
lazyforward::lazyforward("mutate_", asNamespace("dplyr"))
#> function (.data, ...)
#> {
#> mutate_(.dots = lazyeval::lazy_dots(...), .data = .data)
#> }
#> <environment: namespace:dplyr>
dplyr::mutate
#> function(.data, ...) {
#> mutate_(.data, .dots = lazyeval::lazy_dots(...))
#> }
#> <environment: namespace:dplyr>
The difference: You don't need to remember updating the interface and the forwarding logic if the interface of the SE version changes.
If the forwarding logic has been already written by hand, it may be simpler just to verify that it is correct:
testthat::with_reporter(
"summary",
testthat::test_that(
"mutate forwarder is implemented correctly",
lazyforward::expect_lazyforward("mutate", env = asNamespace("dplyr"))
)
)
#> ...
#> DONE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.