问题
Consider this R package with two functions, one exported and the other internal
hello.R
#' @export
hello <- function() {
internalFunctions:::hello_internal()
}
hello_internal.R
hello_internal <- function(x){
print("hello world")
}
NAMESPACE
# Generated by roxygen2 (4.1.1): do not edit by hand
export(hello)
When this is checked (devtools::check()
) it returns the NOTE
There are ::: calls to the package's namespace in its code. A package
almost never needs to use ::: for its own objects:
‘hello_internal’
Question
Given the NOTE
says almost never, under what circumstances will a package need to use :::
for its own objects?
Extra
I have a very similar related question where I do require the :::
for an internal function, but I don't know why it's required. Hopefully having an answer to this one will solve that one. I have a suspicion that unlocking the environment is doing something I'm not expecting, and thus having to use :::
on an internal function.
If they are considered duplicates of each other I'll delete the other one.
回答1:
You should never need this in ordinary circumstances. You may need it if you are calling the parent function in an unusual way (for example, you've manually changed its environment, or you're calling it from another process where the package isn't attached).
来源:https://stackoverflow.com/questions/36852140/when-does-a-package-need-to-use-for-its-own-objects