rwa*_*ace 2 common-lisp clozure-cl
我正在尝试在CCL下运行程序,这样当程序因任何原因完成运行时,它应该退回到操作系统.目前使用此命令行(在Windows上):
\ccl\wx86cl -l test.lisp -e (quit)
Run Code Online (Sandbox Code Playgroud)
当程序成功运行到正常完成时退出,但如果出现内存不足等错误,则会在调试器中结束.如果出现错误,你怎么告诉Clozure也退出?
您不仅要捕获所有错误,还要阻止在INVOKE-DEBUGGER调用时进入调试器.您可以设置*DEBUGGER-HOOK*为退出未处理错误的函数.
$ ./bin/ccl/lx86cl64
Clozure Common Lisp Version 1.11.5/v1.11.5 (LinuxX8664)
For more information about CCL, please see http://ccl.clozure.com.
CCL is free software. It is distributed under the terms of the Apache
Licence, Version 2.0.
? *debugger-hook*
NIL
? (setf *debugger-hook*
(lambda (error hook)
(declare (ignore hook))
(format *error-output* "Crash: ~a" error)
(quit)))
#<Anonymous Function #x302000998C3F>
Run Code Online (Sandbox Code Playgroud)
现在,用未处理的错误测试它:
? (error "Oh no")
Crash: Oh no
Run Code Online (Sandbox Code Playgroud)
然后,你回到了shell.
请注意,BREAK始终进入调试器,因为它绑定*debugger-hook*到NIL(这是故意的,用于调试).
| 归档时间: |
|
| 查看次数: |
111 次 |
| 最近记录: |