Having just talked about restart-bind, we’ll now look at restart-case. The restart-bind might be used to implement restart-case, but there are differences between the syntax and behaviour for these two macros. The most obvious difference from the programmer’s perspective is in what happens after a restart is invoked. In the case of restart-bind, the execution continues after the invoke-restart call. In the case of restart-case, the entire restart-case form exits, and the values returned by the restart, if any, are returned. Here is a simple example of the two different behaviours:
CL-USER> (restart-bind ((say-hi #'(lambda () (format t "Hello~%") (values 1 2 3)))) (progn (format t "Printing before the restart~%") (invoke-restart 'say-hi) (format t "Printing after the restart~%") (format t "Returning the value 10~%") 10)) Printing before the restart Hello Printing after the restart Returning the value 10 10 CL-USER> (restart-case (progn (format t "Printing before the restart~%") (invoke-restart 'say-hi) (format t "Printing after the restart~%") (format t "Returning the value 10~%") 10) (say-hi () (format t "Hello~%") (values 1 2 3))) Printing before the restart Hello 1 2 3