Hi Gabor, nice to see you on this thread. As you see, I'm back with my old problem.
Gabor Grothendieck wrote: > If the intention is to place fList's contents in the global > environment > then you need to specify that in addtoenv or else it assumes > the parent environment. No, it was the intention to keep the global environment as clean as possible and to use local data structures instead. >> flistA <- list(foo = function () 1:10, bar = function() log(foo())) >> makefun <- function(fList) addtoenv(fList, .GlobalEnv) >> makefun(flistA) > $foo > function() { > 1:10 > } > > $bar > function() { > log(foo()) > } > >> foo() > [1] 1 2 3 4 5 6 7 8 9 10 >> bar() > [1] 0.0000000 0.6931472 1.0986123 1.3862944 1.6094379 1.7917595 1.9459101 > [8] 2.0794415 2.1972246 2.3025851 > > Note that this takes advantage of the fact that in your example > flistA was > defined in the global environment in the first place. Had that not > been the > case we would have had to reset the environment of bar so that it > could find foo. > > By the way. What about just attach(flistA) ? You are right, attach works. I used it in another package instead of addtoenv, but it introduced new problems, even if I use it the following way: attach(flist) on.exit(detach(flist)) [...] Additionally, I've never seen attach in another package. Thomas P. ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel