| |
| |
About the Author | |
| |
| |
About the Technical Reviewer | |
| |
| |
Acknowledgments | |
| |
| |
Typographical Conventions | |
| |
| |
| |
Introduction: Why Lisp? | |
| |
| |
Why Lisp? | |
| |
| |
Where It Began | |
| |
| |
Who This Book Is For | |
| |
| |
| |
Lather, Rinse, Repeat: A Tour of the REPL | |
| |
| |
Choosing a Lisp Implementation | |
| |
| |
Getting Up and Running with Lisp in a Box | |
| |
| |
Free Your Mind: Interactive Programming | |
| |
| |
Experimenting in the REPL | |
| |
| |
"Hello, World," Lisp Style | |
| |
| |
Saving Your Work | |
| |
| |
| |
Practical: A Simple Database | |
| |
| |
CDs and Records | |
| |
| |
Filing CDs | |
| |
| |
Looking at the Database Contents | |
| |
| |
Improving the User Interaction | |
| |
| |
Saving and Loading the Database | |
| |
| |
Querying the Database | |
| |
| |
Updating Existing Records-Another Use for WHERE | |
| |
| |
Removing Duplication and Winning Big | |
| |
| |
Wrapping Up | |
| |
| |
| |
Syntax and Semantics | |
| |
| |
What's with All the Parentheses? | |
| |
| |
Breaking Open the Black Box | |
| |
| |
S-expressions | |
| |
| |
S-expressions As Lisp Forms | |
| |
| |
Function Calls | |
| |
| |
Special Operators | |
| |
| |
Macros | |
| |
| |
Truth, Falsehood, and Equality | |
| |
| |
Formatting Lisp Code | |
| |
| |
| |
Functions | |
| |
| |
Defining New Functions | |
| |
| |
Function Parameter Lists | |
| |
| |
Optional Parameters | |
| |
| |
Rest Parameters | |
| |
| |
Keyword Parameters | |
| |
| |
Mixing Different Parameter Types | |
| |
| |
Function Return Values | |
| |
| |
Functions As Data, a.k.a. Higher-Order Functions | |
| |
| |
Anonymous Functions | |
| |
| |
| |
Variables | |
| |
| |
Variable Basics | |
| |
| |
Lexical Variables and Closures | |
| |
| |
Dynamic, a.k.a. Special, Variables | |
| |
| |
Constants | |
| |
| |
Assignment | |
| |
| |
Generalized Assignment | |
| |
| |
Other Ways to Modify Places | |
| |
| |
| |
Macros: Standard Control Constructs | |
| |
| |
WHEN and UNLESS | |
| |
| |
COND | |
| |
| |
AND, OR, and NOT | |
| |
| |
Looping | |
| |
| |
DOLIST and DOTIMES | |
| |
| |
DO | |
| |
| |
The Mighty LOOP | |
| |
| |
| |
Macros: Defining Your Own | |
| |
| |
The Story of Mac: A Just-So Story | |
| |
| |
Macro Expansion Time vs. Runtime | |
| |
| |
DEFMACRO | |
| |
| |
A Sample Macro: do-primes | |
| |
| |
Macro Parameters | |
| |
| |
Generating the Expansion | |
| |
| |
Plugging the Leaks | |
| |
| |
Macro-Writing Macros | |
| |
| |
Beyond Simple Macros | |
| |
| |
| |
Practical: Building a Unit Test Framework | |
| |
| |
Two First Tries | |
| |
| |
Refactoring | |
| |
| |
Fixing the Return Value | |
| |
| |
Better Result Reporting | |
| |
| |
An Abstraction Emerges | |
| |
| |
A Hierarchy of Tests | |
| |
| |
Wrapping Up | |
| |
| |
| |
Numbers, Characters, and Strings | |
| |
| |
Numbers | |
| |
| |
Numeric Literals | |
| |
| |
Basic Math | |
| |
| |
Numeric Comparisons | |
| |
| |
Higher Math | |
| |
| |
Characters | |
| |
| |
Character Comparisons | |
| |
| |
Strings | |
| |
| |
String Comparisons | |
| |
| |
| |
Collections | |
| |
| |
Vectors | |
| |
| |
Subtypes of Vector | |
| |
| |
Vectors As Sequences | |
| |
| |
Sequence Iterating Functions | |
| |
| |
Higher-Order Function Variants | |
| |
| |
Whole Sequence Manipulations | |
| |
| |
Sorting and Merging | |
| |
| |
Subsequence Manipulations | |
| |
| |
Sequence Predicates | |
| |
| |
Sequence Mapping Functions | |
| |
| |
Hash Tables | |
| |
| |
Hash Table Iteration | |
| |
| |
| |
They Called It LISP for a Reason: List Processing | |
| |
| |
"There Is No List" | |
| |
| |
Functional Programming and Lists | |
| |
| |
"Destructive" Operations | |
| |
| |
Combining Recycling with Shared Structure | |
| |
| |
List-Manipulation Functions | |
| |
| |
Mapping | |
| |
| |
Other Structures | |
| |
| |
| |
Beyond Lists: Other Uses for Cons Cells | |
| |
| |
Trees | |
| |
| |
Sets | |
| |
| |
Lookup Tables: Alists and Plists | |
| |
| |
DESTRUCTURING-BIND | |
| |
| |
| |
Files and File I/O | |
| |
| |
Reading File Data | |
| |
| |
Reading Binary Data | |
| |
| |
Bulk Reads | |
| |
| |
File Output | |
| |
| |
Closing Files | |
| |
| |
Filenames | |
| |
| |
How Pathnames Represent Filenames | |
| |
| |
Constructing New Pathnames | |
| |
| |
Two Representations of Directory Names | |
| |
| |
Interacting with the File System | |
| |
| |
Other Kinds of I/O | |
| |
| |
| |
Practical: A Portable Pathname Library | |
| |
| |
The API | |
| |
| |
FEATURES and Read-Time Conditionalization | |
| |
| |
Listing a Directory | |
| |
| |
Testing a File's Existence | |
| |
| |
Walking a Directory Tree | |
| |
| |
| |
Object Reorientation: Generic Functions | |
| |
| |
Generic Functions and Classes | |
| |
| |
Generic Functions and Methods | |
| |
| |
DEFGENERIC | |
| |
| |
DEFMETHOD | |
| |
| |
Method Combination | |
| |
| |
The Standard Method Combination | |
| |
| |
Other Method Combinations | |
| |
| |
Multimethods | |
| |
| |
To Be Continued | |
| |
| |
| |
Object Reorientation: Classes | |
| |
| |
DEFCLASS | |
| |
| |
Slot Specifiers | |
| |
| |
Object Initialization | |
| |
| |
Accessor Functions | |
| |
| |
WITH-SLOTS and WITH-ACCESSORS | |
| |
| |
Class-Allocated Slots | |
| |
| |
Slots and Inheritance | |
| |
| |
Multiple Inheritance | |
| |
| |
Good Object-Oriented Design | |
| |
| |
| |
A Few FORMAT Recipes | |
| |
| |
The FORMAT Function | |
| |
| |
FORMAT Directives | |
| |
| |
Basic Formatting | |
| |
| |
Character and Integer Directives | |
| |
| |
Floating-Point Directives | |
| |
| |
English-Language Directives | |
| |
| |
Conditional Formatting | |
| |
| |
Iteration | |
| |
| |
Hop, Skip, Jump | |
| |
| |
And More | |
| |
| |
| |
Beyond Exception Handling: Conditions and Restarts | |
| |
| |
The Lisp Way | |
| |
| |
Conditions | |
| |
| |
Condition Handlers | |
| |
| |
Restarts | |
| |
| |
Providing Multiple Restarts | |
| |
| |
Other Uses for Conditions | |
| |
| |
| |
The Special Operators | |
| |
| |
Controlling Evaluation | |
| |
| |
Manipulating the Lexical Environment | |
| |
| |
Local Flow of Control | |
| |
| |
Unwinding the Stack | |
| |
| |
Multiple Values | |
| |
| |
EVAL-WHEN | |
| |
| |
Other Special Operators | |
| |
| |
| |
Programming in the Large: Packages and Symbols | |
| |
| |
How the Reader Uses Packages | |
| |
| |
A Bit of Package and Symbol Vocabulary | |
| |
| |
Three Standard Packages | |
| |
| |
Defining Your Own Packages | |
| |
| |
Packaging Reusable Libraries | |
| |
| |
Importing Individual Names | |
| |
| |
Packaging Mechanics | |
| |
| |
Package Gotchas | |
| |
| |
| |
LOOP for Black Belts | |
| |
| |
The Parts of a LOOP | |
| |
| |
Iteration Control | |
| |
| |
Counting Loops | |
| |
| |
Looping Over Collections and Packages | |
| |
| |
Equals-Then Iteration | |
| |
| |
Local Variables | |
| |
| |
Destructuring Variables | |
| |
| |
Value Accumulation | |
| |
| |
Unconditional Execution | |
| |
| |
Conditional Execution | |
| |
| |
Setting Up and Tearing Down | |
| |
| |
Termination Tests | |
| |
| |
Putting It All Together | |
| |
| |
| |
Practical: A Spam Filter | |
| |
| |
The Heart of a Spam Filter | |
| |
| |
Training the Filter | |
| |
| |
Per-Word Statistics | |
| |
| |
Combining Probabilities | |
| |
| |
Inverse Chi Square | |
| |
| |
Training the Filter | |
| |
| |
Testing the Filter | |
| |
| |
A Couple of Utility Functions | |
| |
| |
Analyzing the Results | |
| |
| |
What's Next | |
| |
| |
| |
Practical: Parsing Binary Files | |
| |
| |
Binary Files | |
| |
| |
Binary Format Basics | |
| |
| |
Strings in Binary Files | |
| |
| |
Composite Structures | |
| |
| |
Designing the Macros | |
| |
| |
Making the Dream a Reality | |
| |
| |
Reading Binary Objects | |
| |
| |
Writing Binary Objects | |
| |
| |
Adding Inheritance and Tagged Structures | |
| |
| |
Keeping Track of Inherited Slots | |
| |
| |
Tagged Structures | |
| |
| |
Primitive Binary Types | |
| |
| |
The Current Object Stack | |
| |
| |
| |
Practical: An ID3 Parser | |
| |
| |
Structure of an ID3v2 Tag | |
| |
| |
Defining a Package | |
| |
| |
Integer Types | |
| |
| |
String Types | |
| |
| |
ID3 Tag Header | |
| |
| |
ID3 Frames | |
| |
| |
Detecting Tag Padding | |
| |
| |
Supporting Multiple Versions of ID3 | |
| |
| |
Versioned Frame Base Classes | |
| |
| |
Versioned Concrete Frame Classes | |
| |
| |
What Frames Do You Actually Need? | |
| |
| |
Text Information Frames | |
| |
| |
Comment Frames | |
| |
| |
Extracting Information from an ID3 Tag | |
| |
| |
| |
Practical: Web Programming with AllegroServe | |
| |
| |
A 30-Second Intro to Serve-Side Web Programming | |
| |
| |
AllegroServe | |
| |
| |
Generating Dynamic Content with AllegroServe | |
| |
| |
Generating HTML | |
| |
| |
HTML Macros | |
| |
| |
Query Parameters | |
| |
| |
Cookies | |
| |
| |
A Small Application Framework | |
| |
| |
The Implementation | |
| |
| |
| |
Practical: An MP3 Database | |
| |
| |
The Database | |
| |
| |
Defining a Schema | |
| |
| |
Inserting Values | |
| |
| |
Querying the Database | |
| |
| |
Matching Functions | |
| |
| |
Getting at the Results | |
| |
| |
Other Database Operations | |
| |
| |
| |
Practical: A Shoutcast Server | |
| |
| |
The Shoutcast Protocol | |
| |
| |
Song Sources | |
| |
| |
Implementing Shoutcast | |
| |
| |
| |
Practical: An MP3 Browser | |
| |
| |
Playlists | |
| |
| |
Playlists As Song Sources | |
| |
| |
Manipulating the Playlist | |
| |
| |
Query Parameter Types | |
| |
| |
Boilerplate HTML | |
| |
| |
The Browse Page | |
| |
| |
The Playlist | |
| |
| |
Finding a Playlist | |
| |
| |
Running the App | |
| |
| |
| |
Practical: An HTML Generation Library, the Interpreter | |
| |
| |
Designing a Domain-Specific Language | |
| |
| |
The FOO Language | |
| |
| |
Character Escaping | |
| |
| |
Indenting Printer | |
| |
| |
HTML Processor Interface | |
| |
| |
The Pretty Printer Backend | |
| |
| |
The Basic Evaluation Rule | |
| |
| |
What's Next? | |
| |
| |
| |
Practical: An HTML Generation Library, the Compiler | |
| |
| |
The Compiler | |
| |
| |
FOO Special Operators | |
| |
| |
FOO Macros | |
| |
| |
The Public API | |
| |
| |
The End of the Line | |
| |
| |
| |
Conclusion: What's Next? | |
| |
| |
Finding Lisp Libraries | |
| |
| |
Interfacing with Other Languages | |
| |
| |
Make It Work, Make It Right, Make It Fast | |
| |
| |
Delivering Applications | |
| |
| |
Where to Go Next | |
| |
| |
Index | |