A Complete Guide to Common Lisp Programming from First Principles to Advanced Metaprogramming
Introduction: Why Lisp Still Matters
- What You Will Learn
- How to Use This Book
- The Lisp Mindset
Chapter 1: The Lisp Way of Thinking
- A Language That Thought Differently
- Code as Data: The Fundamental Insight
- Installing Your First Lisp Environment
- Reading Your First S-Expression
- Interactive Development: The REPL as Your Laboratory
Chapter 2: Core Syntax and Data Structures
- Atoms, Symbols and Literals
- Lists: The Foundation of Everything
- Vectors, Arrays and Hash Tables
- Strings and Characters
- Type System Overview
Chapter 3: Functions and Control Flow
- Defining Functions with DEFUN
- Lambda Expressions and Anonymous Functions
- Conditionals: IF, COND and, OR, WHEN, UNLESS
- Loops: The LOOP Macro and Alternatives
- Multiple Values
Chapter 4: Recursion and Higher-Order Programming
- Recursive Thinking: From Iteration to Recursion
- MAPCAR, REDUCE and Functional Higher-Order Tools
- Closures: Functions That Remember
- Tail Call Optimization and Efficient Recursion
- Building Your Own Higher-Order Utilities
Chapter 5: Lexical Scope and the Environment Model
- Lexical Binding and LET Forms
- Dynamic Binding and Special Variables
- Parameter Passing: Required, Optional, Rest and Keyword Arguments
- The Environment Model: How Lisp Resolves Names
- Common Scoping Pitfalls and How to Avoid Them
Chapter 6: Macros and Metaprogramming
- Why Macros Exist: The Limits of Functions
- Your First Macro: DEFMACRO Explained Step by Step
- Pattern Matching and Template Writing
- Hygienic Concerns and Variable Capture
- Real-World Macros: DSLs, Domain-Specific Languages
- Advanced Metaprogramming: Compile-Time Computation
Chapter 7: The Common Lisp Object System (CLOS)
- Classes and Instances: DEFCLASS and Slot Definitions
- Generic Functions and Multiple Dispatch
- Method Combination: Beyond Simple Inheritance
- The Metaobject Protocol: Programming the Object System
- Practical OOP in Lisp: When to Use CLOS
Chapter 8: Error Handling and the Condition System
- Conditions vs Exceptions: A Different Model
- Signaling Errors and Warnings
- Handlers and Restart Functions
- Defining Custom Conditions and Restarts
- Interactive Debugging with the Condition System
Chapter 9: Packages and Modular Programming
- The Package System: Namespaces Done Right
- Exporting and Importing: Controlling Visibility
- Project Structure for Real Applications
- Build Systems: ASDF and Quicklisp
- Testing Frameworks: FiveAM and Test Driven Development
Chapter 10: Performance and Optimization
- Understanding SBCL’s Compilation Model
- Type Declarations: Telling the Compiler What You Know
- Profiling and Measuring Performance
- Memory Management and Garbage Collection
- When to Optimize: Premature Optimization in a Dynamic Language
Chapter 11: Concurrency and Parallelism
- Threads in Common Lisp
- Synchronization Primitives
- Shared State and Race Conditions
- Message Passing and Actor-Like Patterns
- Parallel Computation: Dividing Work Across Cores
Chapter 12: Building Real Applications
- Web Development with Lisp
- Database Access and Persistence
- Interoperability: Calling C, FFI and Foreign Libraries
- Command-Line Tools and Daemons
- Modern Development Workflows
Conclusion: The Future of Lisp Thinking
- What You Have Learned
- Lisp’s Influence on Modern Programming
- Why Lisp Remains Relevant
- Career Considerations
- The Lisp Community
- Continuing Your Journey
- Final Thoughts