

   restart {base}                               R Documentation

   RReessttaarrtt aann EExxpprreessssiioonn

   DDeessccrriippttiioonn::

        `restart' performs a type of non-local return.

   UUssaaggee::

        restart(on = TRUE)

   AArrgguummeennttss::

         on: if true a jump point is set; if false the jump
             point is removed

   DDeettaaiillss::

        When `restart' is called with `on = TRUE' the evaluator
        marks that function as a return point. Any errors or
        signals (such as control-C on Unix) cause control to
        return to the start of the function containing the call
        to `restart'. The most recently established function is
        always entered first.

   NNoottee::

        Use of this code is likely to result in an infinite
        loop. It should be avoided if possible and is included
        in R for compatibility with S. The planned R exception
        handling should remove all need for such a function.

   EExxaammpplleess::

        f <- function(x, first = TRUE)
        {
             restart(first)
             if( first ) {
                first <- FALSE
                return(log(x))
             }
             else
                return(NA)
        }
        f("a")

