^
Начало
Установить закладку
+ Настройки
14 | 16 | 18 | 20 | 22 | 24
Ширина текста:
50% | 60% | 70% | 80% | 90% | 100%
Шрифт:
Цвет текста:
Установить
Цвет фона:
Установить
Сбросить настройки
Why Lisp?
Where It Began
Who This Book Is For
2. 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
3. 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
4. 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
5. 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
6. Variables
Variable Basics
Lexical Variables and Closures
Dynamic, a.k.a. Special, Variables
Constants
Assignment
Generalized Assignment
Other Ways to Modify Places
7. Macros: Standard Control Constructs
WHEN and UNLES
COND
AND, OR, and NOT
Looping
DOLIST and DOTIMES
DO
The Mighty LOOP
8. 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
9. 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
10. Numbers, Characters, and Strings
Numbers
Numeric Literals
Basic Math
Numeric Comparisons
Higher Math
Characters
Character Comparisons
Strings
String Comparisons
11. 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
12. 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
13. Beyond Lists: Other Uses for Cons Cells
Trees
Sets
Lookup Tables: Alists and Plists
DESTRUCTURING-BIND
14. 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
15. Practical: A Portable Pathname Library
The API
*FEATURES* and Read-Time Conditionalization
Listing a Directory
Testing a File's Existence
Walking a Directory Tree
16. 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 . . .
17. 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
18. 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 . . .
19. Beyond Exception Handling: Conditions and Restarts
The Lisp Way
Conditions
Condition Handlers
Restarts
Providing Multiple Restarts
Other Uses for Conditions
20. The Special Operators
Controlling Evaluation
Manipulating the Lexical Environment
Local Flow of Control
Unwinding the Stack
Multiple Values
EVAL-WHEN
Other Special Operators
21. 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
22. 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
23. 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
24. 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
25. 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
26. Practical: Web Programming with AllegroServe
A 30-Second Intro to Server-Side Web Programming
AllegroServe
Generating Dynamic Content with AllegroServe
Generating HTML
HTML Macros
Query Parameters
Cookies
A Small Application Framework
The Implementation
27. Practical: An MP3 Database
The Database
Defining a Schema
Inserting Values
Querying the Database
Matching Functions
Getting at the Results
Other Database Operations
28. Practical: A Shoutcast Server
The Shoutcast Protocol
Song Sources
Implementing Shoutcast
29. 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
30. 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?
31. Practical: An HTML Generation Library, the Compiler
The Compiler
FOO Special Operators
FOO Macros
The Public API
The End of the Line
32. 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