Displaying 1 result from an estimated 1 matches for "prevenv".
Did you mean:
prevent
2005 Mar 08
2
Bug in handling of promises?
...working on a function that does adaptive sampling, and I thought
it would be handy to return the function's environment as part of the
result so that I could re-use local variables in a subsequent run. My
first try didn't work, and it came down to code like this:
> f <- function( H, prevEnv = NULL) {
+ if (!is.null(prevEnv)) H <- prevEnv$H
+ cat('Evaluate H to get ', H(1), '\n')
+ return(environment(NULL))
+ }
I thought that evaluating H would force it, so that H would be
available in the environment returned by the function. But this is
not so:
>...