Skip to main content

restart

restart System Class

Class Precedence List:

restart, t

Description:

An object of type restart represents a function that can be called to perform some form of recovery action, usually a transfer of control to an outer point in the running program.

An implementation is free to implement a restart in whatever manner is most convenient; a restart has only dynamic extent relative to the scope of the binding form which establishes it.

compute-restarts

Expanded Reference: restart

The restart System Class

restart is the system class for restart objects. Restarts represent points to which control can be transferred, typically established by restart-case, restart-bind, or with-simple-restart.

Inspecting Restart Objects

Restart objects are returned by find-restart and compute-restarts. You can query them with restart-name.

(restart-case
(let ((r (find-restart 'my-restart)))
(format nil "Restart: ~A, name: ~S"
r (restart-name r)))
(my-restart ()
:report "Do something."
nil))

=> "Restart: Do something., name: MY-RESTART"

Restarts Are Not Conditions

Restarts and conditions are separate concepts. Conditions describe what went wrong; restarts describe what can be done about it.

(restart-case
(let ((restarts (compute-restarts)))
(every (lambda (r) (typep r 'restart)) restarts))
(my-restart () nil))

=> T

Anonymous Restarts

Restarts can be anonymous (having a name of nil). They cannot be found by find-restart with a symbol argument, but they appear in compute-restarts.

(restart-case
(mapcar #'restart-name (compute-restarts))
(nil ()
:report "An anonymous restart."
nil))

The result will include NIL for the anonymous restart, along with any system-supplied restarts.