Skip to content
Prev 44078 / 63424 Next

Is invokeRestart("abort") unstoppable?

On 09/11/2012 04:19 PM, Henrik Bengtsson wrote:
Not sure what 'currently evaluating R code' means, but

   f = function(x) {
       on.exit(cat("not dead yet\n"))
       invokeRestart("abort")
   }

 > f()
never say die

   g = function() {
       reg.finalizer(new.env(), function(...)
           cat("not dead yet\n"))
       invokeRestart("abort")
   }
 > g()
 > gc()
not dead yet
          used (Mb) gc trigger (Mb) max used (Mb)
Ncells 170841  9.2   47185920 2520   709729 38.0
Vcells 145992  1.2  268435456 2048  1023614  7.9

   h = function() {
       withRestarts(f(), abort=function(...) {
           cat("I'm sorry Henrik, I can't do that\n")
           TRUE
        })
   }

 > h()
never say die
I'm sorry Henrik, I can't do that
[1] TRUE

all evaluate code after invoking abort.
$ svn blame conditions.Rd

says that the line you quote is from r25527 (which is when tryCatch 
appears to have been introduced), and

$ svn info -r25527
Path: man
URL: https://svn.r-project.org/R/trunk/src/library/base/man
Repository Root: https://svn.r-project.org/R
Repository UUID: 00db46b3-68df-0310-9c12-caf00c1e9a41
Revision: 25527
Node Kind: directory
Last Changed Author: luke
Last Changed Rev: 25527
Last Changed Date: 2003-07-31 12:35:18 -0700 (Thu, 31 Jul 2003)