Displaying 1 result from an estimated 1 matches for "target_environment".
2011 Aug 12
1
Can the environment of a function be specified when the function is defined?
...llo,
Is there a syntax to set the environment of a function when this function is
defined?
The best I could come up with so far is using a wrapper function:
foo_internals<- function(x) {"Code of the function"}
foo<- function(x) {
environment(foo_internals)<-as.environment(target_environment)
foo_internals(x)
}
But I would like to know if there is a cleaner syntax.
There are two reasons why I would like to have a function defined with an
environment different then the local one:
The first is to develop a function that will go in a package: there might be
more things loaded in my R_...