Common Lisp 中有停止解释器的命令吗?

发布于 2024-10-07 10:29:02 字数 197 浏览 0 评论 0原文

我正在寻找一个表达式,它会导致解释器在求值时退出。

我发现了很多特定于实现的内容,但在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

药祭#氼 2024-10-14 10:29:02

由于大多数 Lisps 将退出函数导入到 CL-USER 中,因此 CL-USER::QUIT 是一个很好的猜测,无需知道具体实现的包在哪里。

(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.

(cl-user::quit)

Note the two colons, since QUIT does not need to be exported from the CL-USER package.

遗失的美好 2024-10-14 10:29:02

据我所知,规范中没有涵盖这一点,您将不得不使用特定于实现的解决方案,或者尝试看看是否有人已经编写了一个简单的退出库(或者在 CLiki)。

如果你只关心交互使用,SLIME 中的 ,q 总是会做正确的事情。否则,您可以使用如下读取时条件:

(defun my-quit ()
  #+sbcl (sb-ext:quit)
  #+clisp (ext:exit)
  #+ccl (ccl:quit)
  #+allegro (excl:exit)) ;; and so on ...

#+检查以下符号是否在 *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:

(defun my-quit ()
  #+sbcl (sb-ext:quit)
  #+clisp (ext:exit)
  #+ccl (ccl:quit)
  #+allegro (excl:exit)) ;; and so on ...

#+ 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).

金兰素衣 2024-10-14 10:29:02

没有退出 CL 环境的标准方法。要了解如何在您正在使用的实现中执行此操作,请阅读其文档。

在 sbcl 中,(sb-ext:quit) 就可以解决问题。对于 clisp,它是 (ext:exit)。该命令的 clisp 文档位于 http://clisp.sourceforge.net/impnotes.html#quit

There 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

白龙吟 2024-10-14 10:29:02

您可以使用(uiop:quit)。大多数 Lisp 中都包含这一点。

You can use (uiop:quit). This is included in most lisps.

腹黑女流氓 2024-10-14 10:29:02

有一个名为 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文