首页 > 解决方案 > 为什么运球会产生一个空文件?

问题描述

我正在尝试通过Common Lisp:符号计算的简单介绍一书来学习 Common Lisp 。此外,我正在使用 SBCL、Emacs 和 Slime。

在第 9 章的最后,作者展示了运球工具。他展示了以下内容:

在此处输入图像描述 在此处输入图像描述

我试图重现作者提出的命令。考虑到输入,唯一的区别是我放置了不同的位置来保存文件。在我的环境中,我做了:

CL-USER> (dribble "/home/pedro/miscellaneous/misc/symbolic-computation/teste-tool.log")
; No value
CL-USER> (cons 2 nil)
(2)
CL-USER> '(is driblle really working?)
(IS DRIBLLE REALLY WORKING?)
CL-USER> "is dribble useful at all?"
"is dribble useful at all?"
CL-USER> (dribble)
; No value

该文件确实已创建:

$ readlink -f teste-tool.log 
/home/pedro/miscellaneous/misc/symbolic-computation/teste-tool.log

请注意,我在输入时没有在 REPL 中收到诸如“现在在文件中记录 --location ---”之类的消息。但这可能会根据 Lisp 实现而有所不同。

令人惊讶的是,不幸的是,该文件是空的。因此,运球没有按预期工作。

我做错什么了吗?

标签: common-lispread-eval-print-loopsbclslime

解决方案


  1. 是的,默认情况下,在 Slime 中,我认为这不起作用。

  2. 它将在 SBCL Repl 中工作

➜ sbcl
This is SBCL 2.0.1.debian, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
* (dribble "dribble-test.lisp")
* (* 8 5)

40
* "Will this work?"

"Will this work?"
* (dribble)

* %

可以确认的:

➜ cat dribble-test.lisp
* (* 8 5)

40
* "Will this work?"

"Will this work?"
* (dribble)
  1. 使用 Slime IMO 保存“REPL 历史”似乎不太有用,因为您通过选择一个函数或表达式或区域并在 REPL 中对其进行评估来执行所有“非 REPL 评估”。

  2. 要在 Slime 中实际保存和查看历史记录,请参阅slime-repl-save-history和相关功能;如果您愿意,您甚至可以合并来自独立Repls的历史:-)


推荐阅读