views:

82

answers:

2

I'm trying to learn common lisp currently and I've been using sbcl (I hope that's a decent implementation choice.)

Coming from ruby and irb I find the automatic moved to a debugger on every mistake a little annoying at this time. Is there a way to turn it off temporarily when I'm playing around.

+6  A: 

There is a --disable-debugger command-line option, e.g.:

$ sbcl --disable-debugger

From the man page:

By default when SBCL encounters an error, it enters the builtin debugger, allowing interactive diagnosis and possible intercession. This option disables the debugger, causing errors to print a back‐trace and exit with status 1 instead -- which is a mode of operation better suited for batch processing. See the User Manual on SB-EXT:DISABLE-DEBUGGER for details.

There are also --noinform and --noprint CL options you may find useful.

Adam Bernier
Good find, I was trying to find a way to prevent it from exiting at the end.
nkassis
+6  A: 

Common Lisp has a variable *debugger-hook*, which can be bound/set to a function.

* (aref "123" 10)

debugger invoked on a SB-INT:INVALID-ARRAY-INDEX-ERROR:
  Index 10 out of bounds for (SIMPLE-ARRAY CHARACTER
                              (3)), should be nonnegative and <3.

Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

(SB-INT:INVALID-ARRAY-INDEX-ERROR "123" 10 3 NIL)
0] 0

* (defun debug-ignore (c h) (declare (ignore h)) (print c) (abort))

DEBUG-IGNORE
* (setf *debugger-hook* #'debug-ignore)

#<FUNCTION DEBUG-IGNORE>
* (aref "123" 10)

#<SB-INT:INVALID-ARRAY-INDEX-ERROR {1002A661D1}>
* 
Rainer Joswig
That works great, I'm sure one day I'll need the debugger but to test things out it's just a little annoying right now :) Thanks for the answer.
nkassis