nka*_*sis 10 lisp debugging sbcl common-lisp
我正在尝试学习常见的lisp,我一直在使用sbcl(我希望这是一个不错的实现选择.)
来自ruby和irb我发现自动移动到调试器上的每个错误在这个时候有点烦人.我玩的时候有没有办法暂时关掉它.
Rai*_*wig 12
Common Lisp有一个变量*debugger-hook*,可以绑定/设置为一个函数.
* (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}>
*
Run Code Online (Sandbox Code Playgroud)
有一个--disable-debugger命令行选项,例如:
$ sbcl --disable-debugger
Run Code Online (Sandbox Code Playgroud)
从手册页:
默认情况下,当SBCL遇到错误时,它会进入内置调试器,从而允许交互式诊断和可能的代理.此选项禁用调试器,导致错误打印后退跟踪并退出状态1 - 这是一种更适合批处理的操作模式.有关详细信息,请参阅SB-EXT上的用户手册:DISABLE-DEBUGGER.
也有--noinform和--noprintCL的选择可能对你有用.