Skip to main content

restart-name

restart-name Function

Syntax:

restart-name restart → name

Arguments and Values:

restart—a restart.

name—a symbol.

Description:

Returns the name of the restart, or nil if the restart is not named.

Examples:

(restart-case 
(loop for restart in (compute-restarts)
collect (restart-name restart))
(case1 () :report "Return 1." 1)
(nil () :report "Return 2." 2)
(case3 () :report "Return 3." 3)
(case1 () :report "Return 4." 4))
(CASE1 NIL CASE3 CASE1 ABORT)
;; In the example above the restart named ABORT was not created
;; explicitly, but was implicitly supplied by the system.

See Also:

compute-restarts find-restart

Expanded Reference: restart-name

Getting the Name of a Restart

restart-name returns the name (a symbol) of a restart object, or nil if the restart is anonymous.

(restart-case
(restart-name (find-restart 'my-restart))
(my-restart () nil))

=> MY-RESTART

Listing Names of All Active Restarts

(restart-case
(mapcar #'restart-name (compute-restarts))
(alpha () :report "Alpha." nil)
(beta () :report "Beta." nil))

The result will be a list including ALPHA, BETA, plus any system-provided restarts such as ABORT.

Anonymous Restarts Have NIL Names

(restart-case
(loop for r in (compute-restarts)
when (null (restart-name r))
collect :anonymous)
(nil () :report "Anonymous restart." nil))

The result will include at least one :ANONYMOUS entry for the unnamed restart.