From hb at biostat.ucsf.edu  Wed Sep 12 01:19:53 2012
From: hb at biostat.ucsf.edu (Henrik Bengtsson)
Date: Tue, 11 Sep 2012 16:19:53 -0700
Subject: [Rd] Is invokeRestart("abort") unstoppable?
Message-ID: <CAFDcVCQCEUGuWcD2nqpzAxMwsao=QT=nkhzG5OZop5hostjsKw@mail.gmail.com>

Hi,

I'm trying to implement an abort() method that works just like stop()
but does not signal the condition such that try() and tryCatch(...,
condition=...) are, contrary to stop(), effectively non-working with
abort() calls.

In order to achieve this, I stumbled upon invokeRestart("abort"), cf.
help("invokeRestart", package="base") that reads "Restarts are used
for establishing recovery protocols. They can be established using
withRestarts. One pre-established restart is an abort restart that
represents a jump to top level.".

So, my current implementation is (roughly):

abort <- function(...) {
 # handling messages etc

 # Fully abort the R evaluation and return to the top level
 invokeRestart("abort")
}

I've tested it in various setups with and without tryCatch(...,
condition=...) and so on and it appears to work.  Does anyone know if
I'm overlooking something or can I count on  invokeRestart("abort") to
always stop any currently evaluated R code?

Also, does anyone know how far back (in R versions) invokeRestart("abort") goes?

Thxs,

Henrik



[Rd] Is invokeRestart("abort") unstoppable?
Henrik Bengtsson