Created
June 15, 2021 20:35
-
-
Save moodymudskipper/0cd0ac724d0af998a5b65f6e259d490e to your computer and use it in GitHub Desktop.
fake namespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# define `makeNamespace` function | |
eval(body(loadNamespace)[[c(8, 4, 4)]]) | |
ns <- makeNamespace("fake") | |
# define functions | |
ns$foo <- function() "foo!" | |
ns$bar <- function() "bar!" | |
# export some | |
namespaceExport(ns, "foo") | |
#> <environment: 0x0000000011af0248> | |
# `:::` works | |
fake:::foo() | |
#> [1] "foo!" | |
fake:::bar() | |
#> [1] "bar!" | |
# `::` works on unexported functions | |
fake::foo() | |
#> [1] "foo!" | |
fake::bar() | |
#> Error: 'bar' is not an exported object from 'namespace:fake' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment