For information on using this system, please visit this page.
Created attachment 2124 [details] patch for dump.frames() with option to include .GlobalEnv dump.frames() should (optionally) include the global environment in the returned list of environments. This could greatly ease the debugging after a script running in a non-interactive R session with options(error = quote({dump.frames(to.file = TRUE); q(status = 1)})) failed with a non-catastrophic error. I attached a patch which implements the proposed functionality.
(In reply to Andreas Kersting from comment #0) > Created attachment 2124 [details] > patch for dump.frames() with option to include .GlobalEnv > > dump.frames() should (optionally) include the global environment in the > returned list of environments. This could greatly ease the debugging after a > script running in a non-interactive R session with options(error = > quote({dump.frames(to.file = TRUE); q(status = 1)})) failed with a > non-catastrophic error. > > I attached a patch which implements the proposed functionality. Thank you. Your wish seems reasonable to me; the patch as well, apart from as.environment(as.list(.GlobalEnv, all.names = TRUE)) Can you show a case where the above is *different* from .GlobalEnv ?
Created attachment 2136 [details] dump.frames using as.environment(as.list(.GlobalEnv, all.names = TRUE))
Created attachment 2137 [details] dump.frames using only .GlobalEnv
Created attachment 2138 [details] check last.dump for correct content
(In reply to Martin Maechler from comment #1) > (In reply to Andreas Kersting from comment #0) > > Created attachment 2124 [details] > > patch for dump.frames() with option to include .GlobalEnv > > > > dump.frames() should (optionally) include the global environment in the > > returned list of environments. This could greatly ease the debugging after > a > > script running in a non-interactive R session with options(error = > > quote({dump.frames(to.file = TRUE); q(status = 1)})) failed with a > > non-catastrophic error. > > > > I attached a patch which implements the proposed functionality. > > Thank you. Your wish seems reasonable to me; the patch as well, > apart from > > as.environment(as.list(.GlobalEnv, all.names = TRUE)) > > Can you show a case where the above is *different* from .GlobalEnv ? Please consider (see also attached files): andreas@t410debian:~$ Rscript dump.frames_with_as.list.R Creating 'test_object' in the global environment. Done. Throwing a simple error now: Fehler: A simple error! andreas@t410debian:~$ Rscript check_last.dump.R Does 'test_object' exist in last.dump$.GlobalEnv? [1] TRUE What's the content of the environment last.dump$.GlobalEnv? [1] "dump.frames" "test_object" andreas@t410debian:~$ Rscript dump.frames_without_as.list.R Creating 'test_object' in the global environment. Done. Throwing a simple error now: Fehler: A simple error! andreas@t410debian:~$ Rscript check_last.dump.R Does 'test_object' exist in last.dump$.GlobalEnv? [1] FALSE What's the content of the environment last.dump$.GlobalEnv? [1] "last.dump" So when we do not use as.environment(as.list(.GlobalEnv, all.names = TRUE)) but only .GlobalEnv last.dump$.GlobalEnv rather refers to the *current* global environment and not to that of the R session where dump.frames() was called.
Thank you for providing so much evidence. Of course you are right and it is necessary to make a "deep copy" of an environment... and your as.environment(as.list(ENV, all.names=TRUE)) is a workaround for a missing cp_env(EEE) function.
I have committed a version of your patch to R-devel (only), svn -c71102