Search code examples
common-lispslime

Common lisp error , not binding variables


I am following Practical Common Lisp. I have followed the example to the tee. When I compile in Emacs C-c C-c I get the following error with this code.

(defun make-cd (title artist rating ripped)
  (list :title title :artist artist :rating rating :ripped ripped))

(defvar *db* nil)
(defun add-record (cd)(push cd db))

WARNING: in ADD-RECORD : DB is neither declared nor bound, it will be treated as if it were declared SPECIAL.

I can't understand what is going wrong. It cant be the code because I have tried in both clisp and sbcl, both get similar errors. Why is this occurring? Could my set-up be wrong?


Solution

  • You made a copy error from this text:

    (defun add-record (cd) (push cd *db*))
    

    where *db* (mind the * signs) refers to the previous

    (defvar *db* nil)