- Full Description
-
Lisp is often thought of as an academic language, but it need not be. This is the first book that introduces Lisp as a language for the real world.
Practical Common Lisp presents a thorough introduction to Common Lisp, providing you with an overall understanding of the language features and how they work. Over a third of the book is devoted to practical examples, such as the core of a spam filter and a web application for browsing MP3s and streaming them via the Shoutcast protocol to any standard MP3 client software (e.g., iTunes, XMMS, or WinAmp). In other "practical" chapters, author Peter Seibel demonstrates how to build a simple but flexible in-memory database, how to parse binary files, and how to build a unit test framework in 26 lines of code.
- Source Code/Downloads
- Errata
-
If you think that you've found an error in this book, please let us know about it. You will find any confirmed erratum below, so you can check if your concern has already been addressed.
On page 107:Entered the following code:
;; Unit test framework
(defun report-result (result form)
(format t "~:[FAIL~;pass~] ... ~a~%" result form)
result)
(defmacro check (&body forms)
`(combine-results
,@(loop for f in forms collect `(report-result ,f ',f))))
(defmacro combine-results (&body forms)
(with-gensyms (result)
`(let ((,result t))
,@(loop for f in forms collect `(unless ,f (setf ,result nil)))
,result)))
(defun test-+ ()
(check
(= (+ 1 2) 2)
(= (+ 1 2 3) 6)
(= (+ -1 -3) -4)))
GNU CLISP 2.49 gives the following error:
[1]> (load "test.lisp")
;; Loading file test.lisp ...
*** - LET: variable RESULT has no value
The following restarts are available:
USE-VALUE :R1 Input a value to be used instead of RESULT.
STORE-VALUE :R2 Input a new value for RESULT.
SKIP :R3 skip (DEFUN TEST-+ NIL ...)
RETRY :R4 retry (DEFUN TEST-+ NIL ...)
STOP :R5 stop loading file /Users/chuck/lisp/cpl/9/test.lisp
ABORT :R6 Abort main loop
Been away from Lisp for a while, so I haven't been able to track down why it is failing yet.
