Emacs Slime Common LISP未定义变量
我将以下代码保存到外部文件:
(defvar *db* nil)
(defun make-cd (title artist rating ripped)
(list :title title :artist artist :rating rating :ripped ripped))
(defun add-record (cd) (push cd *db*))
(defun dump-db ()
(dolist (cd *db*)
(format t "\~{\~a:\~10t\~a\~%\~}\~%" cd)))
当我尝试在Emacs内部编译时,我会遇到以下错误:
compilation unit finished ;
Undefined variable: ;
*DB* ;
caught 1 WARNING condition
有人可以向我解释代码有什么问题?
编译上述代码与在粘液下运行每条线之间有什么区别?
提前致谢。
以下是我尝试的:
- 如果我尝试编译上述所有代码(最终光标),则会获得未定义的可变警告。
- 如果我尝试编译
(Defvar * db * nil)
然后其余的代码,我不会收到未定义的变量警告(我只是在发布之前尝试过,但是我在以前的尝试中没有得到这个结果,或者也许在以前的尝试中我做了一些额外的事情...)。 我想我明白为什么我没有使用第二种方法遇到错误,因为*db*
已经在内存中。
I'm following Practical Common Lisp Chapter 3 codes.
I've save the following codes to an external files:
(defvar *db* nil)
(defun make-cd (title artist rating ripped)
(list :title title :artist artist :rating rating :ripped ripped))
(defun add-record (cd) (push cd *db*))
(defun dump-db ()
(dolist (cd *db*)
(format t "\~{\~a:\~10t\~a\~%\~}\~%" cd)))
I keep getting the following error when I tried to compile it inside Emacs:
compilation unit finished ;
Undefined variable: ;
*DB* ;
caught 1 WARNING condition
Could someone explain to me what is wrong with the code?
What is the different between compiling the above code vs running each line under SLIME?
thanks in advance.
the following is what i tried:
- If i try compile all the above codes (cursor at very end), i get the undefined variable warning.
- if i try and compile
(defvar *db* nil)
then rest of the code, I don't get the undefined variable warning (i tried this just before posting, but i was not getting this result in previous attempt, or maybe i did something extra in those previous attempts...).
i think i understand why I'm not getting an error with the 2nd method because the*db*
is in memory already.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅《史莱姆手册:
href =》 仅编译单个高级表单。请参阅文档如何编译区域或文件。
See the SLIME manual: Compilation Commands
C-c C-c only compiles individual toplevel forms. See the documentation how to compile a region or file.
正如人们评论的那样 - 这也是我怀疑您没有为整个缓冲区运行编译命令。
要编译整个文件/缓冲区,请执行:
cc ck
。或标记您想要的所有代码
cs -
和upp
,downn
,backb
,向前 f 要运行然后调用
MX Slime-Compile-Region
。As the people commented - that was also my suspicion that you didn't run the compiling command for the entire buffer.
To compile the entire file/buffer, do:
C-c C-k
.Or mark all the code you want by
C-S-
and for upp
, downn
, backb
, forwardf
to be runand then call
M-x slime-compile-region
.