Is it possible to move hand over hand along restarts like this:
(handler-bind ((simple-error #'(lambda(condition)
(write condition)
(invoke-restart 'alle condition))))
(restart-case
(restart-case
(error 'simple-error)
(next (err)))
(alle (err) (invoke-restart 'next))))
this currently leads to an
No restart NEXT is active.
[Condition of type SB-INT:SIMPLE-CONTROL-ERROR]
I want to be able to implement a general restart like “just-log-all-conditions” which then calls the correct restart for any condition signaled within its expression.
You might check if that’s really what you want to do… Typically you want a handler to select the best restart. The handler sees all available restarts. Moving from restart to restart is unusual. IMHO. There is also not a ‘correct’ restart for some condition. Several restarts might be available and useful. This can either be determined programmatically or interactively by the user. A restart might also be useful for several different conditions.
The Common Lisp Condition System has several basic concepts:
conditions, typically implemented as CLOS classes
signalling a condition object, that’s typically done in user code.
handling the condition. Based on the condition a handler is selected and called. When the handler is running it can inspect and decide what to do. A handler typically declines handling the condition or selects one of the available restarts. In a typical development environment, this might involve presenting the restarts and asking the user for a choice.
restarting. The restart then is responsible to get out of the condition situation. Tranfer of control to the restart gets us out of the error context. We can enforce execution of code via ‘UNWIND-PROTECT’. Once we are restarting, the context where the condition was signaled is gone.
That means that only the handler sees all the available restarts and a handler can also transfer control to the next handler.
Jumping from restart to restart is not really part of this model.
For some background on the condition system idea see this text by Kent Pitman: Condition Handling in the Lisp Language Family.