Common Lisp 中有停止解释器的命令吗?
我正在寻找一个表达式,它会导致解释器在求值时退出。
我发现了很多特定于实现的内容,但在 HyperSpec 中没有找到,我想知道是否有一些我在规范中没有看到的定义。我发现 (quit)
可以被 CLISP 和 SLIME 识别,而 (exit)
只能被 CLISP 识别,但是我找不到任何引用的文档其中任何一个。
I'm looking for an expression that will cause the interpreter to exit when it is evaluated.
I've found lots of implementation-specific ones but none in the HyperSpec, and I was wondering if there were any that I wasn't seeing defined in the specification. I've found that (quit)
is recognized by both CLISP and SLIME, and (exit)
is recognized only by CLISP, but I can't find any documentation that references either of these.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
由于大多数 Lisps 将退出函数导入到 CL-USER 中,因此 CL-USER::QUIT 是一个很好的猜测,无需知道具体实现的包在哪里。
请注意两个冒号,因为 QUIT 不需要从 CL-USER 包中导出。
Since most Lisps import a quit function into CL-USER, CL-USER::QUIT is a good guess without knowing the implementation specific package where it is.
Note the two colons, since QUIT does not need to be exported from the CL-USER package.
据我所知,规范中没有涵盖这一点,您将不得不使用特定于实现的解决方案,或者尝试看看是否有人已经编写了一个简单的退出库(或者在 CLiki)。
如果你只关心交互使用,SLIME 中的
,q
总是会做正确的事情。否则,您可以使用如下读取时条件:#+
检查以下符号是否在
*features*
中。如果不是,则以下形式将被视为空白。 (还有#-
用于对面的)。As far as I know, this is not covered by the Spec, and you will have to use the implementation-specific solutions, or maybe try and look if someone has already written a trivial-quit lib (or start one on CLiki).
If you only care about interactive use,
,q
in SLIME will always do the right thing. Otherwise, you may use read-time conditionals like this:#+
checks, if the following symbol is in*features*
. If not, the following form will be treated as white-space. (There is also#-
for the opposite).没有退出 CL 环境的标准方法。要了解如何在您正在使用的实现中执行此操作,请阅读其文档。
在 sbcl 中,
(sb-ext:quit)
就可以解决问题。对于 clisp,它是(ext:exit)
。该命令的 clisp 文档位于 http://clisp.sourceforge.net/impnotes.html#quitThere is no standard way to exit a CL environment. To find out how to do it in the implementation you're using, read its documentation.
In sbcl,
(sb-ext:quit)
will do the trick. For clisp, it's(ext:exit)
. The clisp documentation for the command is at http://clisp.sourceforge.net/impnotes.html#quit您可以使用
(uiop:quit)
。大多数 Lisp 中都包含这一点。You can use
(uiop:quit)
. This is included in most lisps.有一个名为 shutdown-it-down 的 ASDF 库,它提供了
退出 函数只需提供常见 CL 实现的案例即可工作。
There is an ASDF library called shut-it-down that provides a
quit
function that works by just having cases for the common CL implementations.