《实用common lisp编程》中问题求教

赵渊 发布于 2013/08/02 23:41
阅读 627
收藏 0

我用的win7系统,lispbox开发环境。在调试书上第三章,“保存和加载数据库”小节的代码上遇到了问题。求指教.代码如下:

(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)))
(defun prompt-read (prompt)
	(format *query-io* "~a: " prompt)
	(force-output *query-io*)
	(read-line *query-io*))
(defun prompt-for-cd()
	(make-cd
		(prompt-read "Title")
		(prompt-read "Artist")
		(or (parse-integer (prompt-read "Rating") :junk-allowed t) 0)
		(y-or-n-p  "Ripped [Y/n]")))
(defun add-cds ()
    (loop (add-record (prompt-for-cd))
		(if (not (y-or-n-p "Another? [y/n]: ")) (return))))
(defun save-db (filename)
	(with-open-file (out filename
					 :direction :output
					 :if-exists :supersede)
		(with-standard-io-syntax
			(print *db* out))))

调用最后一个方法 save-db 时 出错了,错误信息如下:

Undefined function SAVE-DB called with arguments ("f:/lispCode/make-cd.dat") .
   [Condition of type CCL::UNDEFINED-FUNCTION-CALL]


加载中
0
FreeBlues
FreeBlues

函数没编译, 把光标放在这个函数定义内, C-c C-c 就可以了

返回顶部
顶部