Successful Lisp - Contents Table of Contents ● About the Author ● About the Book ● Dedication ● Credits ● Copyright ● Acknowledgments ● Foreword ● Introduction 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 Appendix A ● Chapter 1 - Why Bother? Or: Objections Answered Chapter objective: Describe the most common objections to Lisp, and answer each with advice on state-of-the-art implementations and previews of what this book will explain. ❍ I looked at Lisp before, and didn't understand it. ❍ I can't see the program for the parentheses. ❍ Lisp is very slow compared to my favorite language. ❍ No one else writes programs in Lisp. ❍ Lisp doesn't let me use graphical interfaces. ❍ I can't call other people's code from Lisp. ❍ Lisp's garbage collector causes unpredictable pauses when my program runs. ❍ Lisp is a huge language. ❍ Lisp is only for artificial intelligence research. ❍ Lisp doesn't have any good programming tools. ❍ Lisp uses too much memory. ❍ Lisp uses too much disk space. ❍ I can't find a good Lisp compiler. ● Chapter 2 - Is this Book for Me? Chapter objective: Describe how this book will benefit the reader, with specific examples and references to chapter contents. ❍ The Professional Programmer http://psg.com/~dlamkins/sl/contents.html (1 of 13)11/3/2006 5:46:04 PM Successful Lisp - Contents ❍ The Student ❍ The Hobbyist ❍ The Former Lisp Acquaintance ❍ The Curious ● Chapter 3 - Essential Lisp in Twelve Lessons Chapter objective: Explain Lisp in its simplest form, without worrying about the special cases that can confuse beginners. ❍ Lesson 1 - Essential Syntax ■ Lists are surrounded by parentheses ■ Atoms are separated by whitespace or parentheses ❍ Lesson 2 - Essential Evaluation ■ A form is meant to be evaluated ■ A function is applied to its arguments ■ A function can return any number of values ■ Arguments are usually not modified by a function ■ Arguments are usually evaluated before function application ■ Arguments are evaluated in left-to-right order ■ Special forms and macros change argument evaluation ❍ Lesson 3 - Some Examples of Special Forms and Macros ■ SETQ ■ LET ■ COND ■ QUOTE ❍ Lesson 4 - Putting things together, and taking them apart ■ CONS ■ LIST ■ FIRST and REST ❍ Lesson 5 - Naming and Identity ■ A symbol is just a name ■ A symbol is always unique ■ A symbol can name a value ■ A value can have more than one name ❍ Lesson 6 - Binding versus Assignment ■ Binding creates a new place to hold a value ■ Bindings have names ■ A binding can have different values at the same time ■ One binding is innermost ■ The program can only access bindings it creates ■ Assignment gives an old place a new value http://psg.com/~dlamkins/sl/contents.html (2 of 13)11/3/2006 5:46:04 PM Successful Lisp - Contents ❍ Lesson 7 - Essential Function Definition ■ DEFUN defines named functions ■ LAMBDA defines anonymous functions ❍ Lesson 8 - Essential Macro Definition ■ DEFMACRO defines named macros ■ Macros return a form, not values ❍ Lesson 9 - Essential Multiple Values ■ Most forms create only one value ■ VALUES creates multiple (or no) values ■ A few special forms receive multiple values ■ Some forms pass along multiple values ❍ Lesson 10 - A Preview of Other Data Types ■ Lisp almost always does the right thing with numbers ■ Characters give Lisp something to read and write ■ Arrays organize data into tables ■ Vectors are one-dimensional arrays ■ Strings are vectors that contain only characters ■ Symbols are unique, but they have many values ■ Structures let you store related data ■ Type information is apparent at runtime ■ Hash Tables provide quick data access from a lookup key ■ Packages keep names from colliding ❍ Lesson 11 - Essential Input and Output ■ READ accepts Lisp data ■ PRINT writes Lisp data for you and for READ ■ OPEN and CLOSE let you work with files ■ Variations on a PRINT theme ❍ Lesson 12 - Essential Reader Macros ■ The reader turns characters into data ■ Standard reader macros handle built-in data types ■ User programs can define reader macros ● Chapter 4 - Mastering the Essentials Chapter objective: Reinforce the concepts of Chapter 3 with hands-on exercises. ❍ Hands-on! The "toploop" ❍ Spotting and avoiding common mistakes ❍ Defining simple functions ❍ Using global variables and constants ❍ Defining recursive functions ❍ Tail recursion http://psg.com/~dlamkins/sl/contents.html (3 of 13)11/3/2006 5:46:04 PM Successful Lisp - Contents ❍ Exercises in naming ❍ Lexical binding and multiple name spaces ❍ Reading, writing, and arithmetic ❍ Other data types ❍ Simple macros ❍ Reader macros ● Chapter 5 - Introducing Iteration Chapter objective: Introduce the most common looping constructs. "There's no such thing as an infinite loop. Eventually, the computer will break." -- John D. Sullivan ❍ Simple LOOP loops forever... ❍ But there's a way out! ❍ Use DOTIMES for a counted loop ❍ Use DOLIST to process elements of a list ❍ DO is tricky, but powerful ● Chapter 6 - Deeper into Structures Chapter objective: Show the most useful optional features of structures. ❍ Default values let you omit some initializers, sometimes ❍ Change the way Lisp prints your structures ❍ Alter the way structures are stored in memory ❍ Shorten slot accessor names ❍ Allocate new structures without using keyword arguments ❍ Define one structure as an extension of another ● Chapter 7 - A First Look at Objects as Fancy Structures Chapter objective: Introduce CLOS objects as tools for structuring data. Object behaviors will be covered in a later chapter. ❍ Hierarchies: Classification vs. containment ❍ Use DEFCLASS to define new objects ❍ Objects have slots, with more options than structures ❍ Controlling access to a slot helps keep clients honest ❍ Override a slot accessor to do things that the client can't ❍ Define classes with single inheritance for specialization http://psg.com/~dlamkins/sl/contents.html (4 of 13)11/3/2006 5:46:04 PM Successful Lisp - Contents ❍ Multiple inheritance allows mix-and-match definition ❍ Options control initialization and provide documentation ❍ This is only the beginning... ● Chapter 8 - Lifetime and Visibility Chapter objective: Show how lifetime and visibility affect the values of Lisp variables during execution. This is pretty much like local and global variables in other languages, but Lisp's special variables change things. This chapter also sets the stage for understanding that lifetime and visibility isn't just for variables. ❍ Everything in Lisp has both lifetime and visibility ❍ Lifetime: Creation, existence, then destruction ❍ Visibility: To see and to be seen by ❍ The technical names: Extent and Scope ❍ Really easy cases: top-level defining forms ❍ Scope and extent of parameters and LET variables ❍ Slightly trickier: special variables ● Chapter 9 - Introducing Error Handling and Non-Local Exits Chapter objective: Show three new ways of transferring control between parts of a program. ❍ UNWIND-PROTECT: When it absolutely, positively has to run ❍ Gracious exits with BLOCK and RETURN-FROM ❍ Escape from anywhere (but not at any time) with CATCH and THROW ❍ Making sure files only stay open as long as needed ● Chapter 10 - How to Find Your Way Around, Part 1 Chapter objective: Show how to find things in Lisp without resorting to the manual. ❍ APROPOS: I don't remember the name, but I recognize the face ❍ DESCRIBE: Tell me more about yourself ❍ INSPECT: Open wide and say "Ah..." ❍ DOCUMENTATION: I know I wrote that down somewhere ● Chapter 11 - Destructive Modification Chapter objective: Illustrate the difference between assignment and binding, and show why assignment is harder to understand. Then explore reasons for preferring the more difficult concept, and introduce functions that use destructive modification. http://psg.com/~dlamkins/sl/contents.html (5 of 13)11/3/2006 5:46:04 PM Successful Lisp - Contents ❍ Simple assignment is destructive modification ❍ The risk of assignment ❍ Changing vs. copying: an issue of efficiency ❍ Modifying lists with destructive functions ❍ RPLACA, RPLACD, SETF ...; circularity ❍ Places vs. values: destructive functions don't always have the desired side-effect ❍ Contrast e.g. PUSH and DELETE ❍ Shared and constant data: Dangers of destructive changes ● Chapter 12 - Mapping Instead of Iteration Chapter objective: Categorize and demonstrate the mapping functions. Show appropriate and inappropriate uses. Introduce the concept of sequences. ❍ MAPCAR, MAPC, and MAPCAN process successive list elements ❍ MAPLIST, MAPL, and MAPCON process successive sublists ❍ MAP and MAP-INTO work on sequences, not just lists ❍ Mapping functions are good for filtering ❍ It's better to avoid mapping if you care about efficiency ❍ Predicate mapping functions test sequences ❍ SOME, EVERY, NOTANY, NOTEVERY ❍ REDUCE combines sequence elements ● Chapter 13 - Still More Things You Can Do with Sequences Chapter objective: Introduce the most useful sequence functions, and show how to use them. Show how destructive sequence functions must be used to have the intended effect. ❍ CONCATENATE: new sequences from old ❍ ELT and SUBSEQ get what you want from any sequence (also, COPY-SEQ) ❍ REVERSE turns a sequence end-for-end (also, NREVERSE) ❍ LENGTH: size counts after all ❍ COUNT: when it's what's inside that matters ❍ REMOVE, SUBSTITUTE, and other sequence changers ❍ DELETE, REMOVE-DUPLICATES, DELETE-DUPLICATES, and NSUBSTITUTE ❍ FILL and REPLACE ❍ Locating things in sequences: POSITION, FIND, SEARCH, and MISMATCH ❍ SORT and MERGE round out the sequence toolkit ●
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages301 Page
-
File Size-