restart
.
restart(on=T, discard=F)
TRUE
,
cause errors to recall the function from
which
restart
was called.
If
FALSE
,
error control is returned to S-PLUS (but see below).
TRUE
discard pending changes
to permanent datasets that not yet been committed
(this is what happens when there is an error that has not been
intercepted by restart).
If
FALSE
act as though there have been no errors:
keep any pending data changes on the queue of things to commit
at the end of the current top level expression.
restart
,
all errors and
interrupts, with one exception,
will not get the user back to the S-PLUS prompt level.
Instead, the function that called
restart
will be recalled,
but with its local frame in the state that obtained when the error occurred.
(
restart
will have been canceled at this point,
but typically the restarted function will
then call
restart
again.)
The quit signal
(usually typed as control-backslash)
will cancel unconditionally the restart
and return the user to S-PLUS prompt level.
Keep in mind that a second quit signal will exit S-PLUS entirely.
(The quit signal has nothing to do with the S-PLUS function
q
.)
This is a function to be used only by the adept and strong at heart.
Use of
restart
can be dangerous to your health
and social standing.
In particular,
if the function calling
restart
has an error,
an infinite loop of errors can easily result;
hence the use of quit as a loop-hole.
ALWAYS make sure that the calling function is bug-free before installing
a call to
restart
.
# prompt for expressions & evaluate them pause <- function() { restart(T) cat("Enter expressions, q to quit from pause\n") repeat { e <- parse(prompt = "<P> ") if(is.name(e[[1]]) && e[[1]]=="q") return() print(eval(e, local = sys.parent(1))) } } # look at browser for another example