Search code examples
lispcommon-lispclisp

Can you auto-continue on continuable error with clisp (or sbcl)?


This seems like an obvious question but my Googling suggests the answer is no, which I find hard to believe. I'm just starting out using examples from textbooks, and get the following. I have to type "continue" 4 times before I can get to my repl (in clisp).

$ clisp  -i auxfns.lsp  -i 4_general_problem_solver.lsp


...


** - Continuable Error
DEFUN/DEFMACRO(DEBUG): #<PACKAGE COMMON-LISP> is locked
If you continue (by typing 'continue'): Ignore the lock and proceed

Notes


Solution

  • Yes, you can. For instance this macro:

    (defmacro continuing (&body forms)
      `(handler-bind
           ((error #'continue))
         ,@forms))
    

    will invoke the continue restart for errors which have one, or where there is a continue restart not associated with any condition.

    You almost never want to do this. In particular, in this case, the system is signalling errors because the program is trying to make modifications to symbols in the CL package. The CL package contains symbols which name all the basic functions and variables of Common Lisp, so this is almost never something you want to do, and certainly it is only something you want to do when you know exactly the consequences of doing that.

    I have no idea why the PAIP code thinks it is reasonable to do this.