Subject: [clisp-list] Interactive interpreter error recovery

From: William Carrington <[email-masked]>
Date: Fri Jul 30 22:48:04 2004

Excuse me if I am being redundant, but I couldn't find a way to search
the archives. If I should be looking at a tutorial, please yell at me
and I will go away. :)

I am new to clisp, and the way it recovers from errors seems very
strange. For example, if I start the interpreter and input at the prompt
"(setq a a)", it tells me that the variable A has no value. Then it
gives me a couple of 'restarts' to choose from, with no indication of
how to choose them, or just tell it to forget about it so that I can
input a completely different statement.

How do I choose one of the options? How do I tell it to ignore that
statement and continue with the session as if I never input the
statement?

--William Carrington

---

From: Edi Weitz <[email-masked]>
Date: Sat Jul 31 00:51:04 2004

On Sat, 31 Jul 2004 00:47:46 -0500, William Carrington <[email-masked]> wrote:

> Excuse me if I am being redundant, but I couldn't find a way to
> search the archives. If I should be looking at a tutorial, please
> yell at me and I will go away. :)
>
> strange. For example, if I start the interpreter and input at the
> prompt "(setq a a)", it tells me that the variable A has no
> value. Then it gives me a couple of 'restarts' to choose from, with
> no indication of how to choose them, or just tell it to forget about
> it so that I can input a completely different statement.
>

Just type in the name of the restart or its abbreviation.

  [1]> (setq a a)

  *** - EVAL: variable A has no value
  The following restarts are available:
  STORE-VALUE    :R1      You may input a new value for A.
  USE-VALUE      :R2      You may input a value to be used instead of A.

  Break 1 [2]> :r1

  New A: 42
  42
  [3]> (setq b b)

  *** - EVAL: variable B has no value
  The following restarts are available:
  STORE-VALUE    :R1      You may input a new value for B.
  USE-VALUE      :R2      You may input a value to be used instead of B.

  Break 1 [4]> store-value

  New B: 43
  43
  [5]> 

You can also type "help" or "?" if you're in the debugger. If you just
want to abort type ":a" (or ":q" to go to the top-level in case you're
several levels deep into the debugger).

The Lisp way of dealing with errors (this is not particular to CLISP
the implementation but a general feature of Common Lisp the language)
may seem strange if you're accustomed to C-like languages but it's
actually very powerful. See

  <http://www.gigamonkeys.com/book/beyond-exception-handling-conditions-and-restarts.html>

for a good explanation.

HTH,
Edi.