Common Lisp: An Interactive Approach

Categories:

Recommended

The purpose of this book is to teach the Common Lisp programming language. The book is intended to be a self-paced study guide, requiring additional information from an instructor, manual, consultant, or friend only to fill in the details of the local operating system and a few implementationdependent features. This book is a Common Lisp version of LISP: An Interactive Approach, published by Computer Science Press in 1986. The major motivation for creating the new version was the widespread adoption of Common Lisp as the standard Lisp dialect. In the earlier edition, I presented Lisp in a dialect-independent way and discussed the different approaches of the major dialects. In this edition, however, I am strictly following the Common Lisp standard set out in Guy L. Steele, Jr.’s COMMON LISP: The Language, Second Edition (Bedford, MA: Digital Press, 1990). (Steele’s book is often referred to as CLtL-2, and I will do so hereafter.) The Lisp version of this book has been used as the text of the Lisp portion of data structures, programming languages, and artificial intelligence courses and as a self-study guide for students, faculty members, and others learning Lisp independently. Draft versions of this book have also been used in Common Lisp courses, artificial intelligence courses, and for self-study.

Lisp is the language of choice for work in artificial intelligence and in symbolic algebra. It is also important in the study of programming languages, because, since its inception over thirty years ago, it has had full recursion, the conditional expression, the equivalence of program and data structure, its own evaluator available to the programmer, and extensibility—the syntactic indistinguishability of programmer-defined functions and “built-in” operators. It is also the paradigm of “functional,” or “applicative,” programming. Because of the varied interests in Lisp, I have tried to present it in a general and neutral setting, rather than specifically in the context of any of the special fields in which it is used.

Above all, Lisp is an interactive language. A Lisp program is not built up from imperative statements, but from forms, each of which has a value. The Lisp programmer sits in front of a terminal, interacting with the Lisp listener. During such a session, a program gets written, read, tested, modified, and saved for future use. Most Lisp implementations provide more than just a programming language, they provide an entire environment including tracing, inspectors, debuggers, and other programmer aids, almost all written in Lisp itself.

I learned Lisp by experimenting with it, typing S-expressions and seeing what happened. That is the learning style I encourage in this book. Teaching Lisp by having the student sit down at a terminal and experiment right from the start influences the order of topics. For peace of mind, the first thing a novice needs to know about being in a new environment is how to get out. Therefore, Chapter 1 is concerned solely with getting into Lisp and getting back out. Lisp input is not tied to line boundaries, and extra spaces are ignored. Students need to experience this flexibility early so they do not feel they are under more constraints than they really are. A novice makes mistakes (and so do we all). Therefore, it is important to show the debugger and error messages early. Since typing errors will occur, backspace and delete keys are important, and the student should experience the entire character set. The general approach is to prepare the student for the unexpected. Since new concepts must be built on existing conceptual structures, numeric examples are used before symbolic examples.

Since the best language for defining Lisp is Lisp itself, many Lisp functions are introduced by having the student define them first. This means that some functions I have been tempted to discuss early have been put off until the student has enough background to define them.

I have written the exercises so that it is reasonable to expect the student to do all of them. Therefore the only long projects are those that are distributed throughout the text as exercises that have the student modify and extend functions that are saved on files.

 

 

Category:

Attribution

Stuart C. Shapiro. Common Lisp: An Interactive Approach. http://www.cse.buffalo.edu/~shapiro/Commonlisp/

VP Flipbook Maker

Convert your work to digital flipbook with VP Online Flipbook Maker! You can also create a new one with the tool. Try it now!