home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / lisp / 2866 < prev    next >
Encoding:
Internet Message Format  |  1992-11-13  |  59.8 KB

  1. Xref: sparky comp.lang.lisp:2866 news.answers:3953
  2. Path: sparky!uunet!gatech!destroyer!cs.ubc.ca!uw-beaver!news.u.washington.edu!ogicse!das-news.harvard.edu!cantaloupe.srv.cs.cmu.edu!crabapple.srv.cs.cmu.edu!mkant
  3. From: mkant+@cs.cmu.edu (Mark Kantrowitz)
  4. Newsgroups: comp.lang.lisp,news.answers
  5. Subject: FAQ: Lisp Frequently Asked Questions 1/6 [Monthly posting]
  6. Summary: Introductory Matter and Bibliography of Introductions and References
  7. Message-ID: <lisp-faq-1.text_721645282@cs.cmu.edu>
  8. Date: 13 Nov 92 09:01:41 GMT
  9. Article-I.D.: cs.lisp-faq-1.text_721645282
  10. Expires: Sun, 27 Dec 1992 09:01:22 GMT
  11. Sender: news@cs.cmu.edu (Usenet News System)
  12. Reply-To: lisp-faq@think.com
  13. Followup-To: poster
  14. Organization: School of Computer Science, Carnegie Mellon
  15. Lines: 1222
  16. Approved: news-answers-request@MIT.Edu
  17. Supersedes: <lisp-faq-1.text_718963271@cs.cmu.edu>
  18. Nntp-Posting-Host: a.gp.cs.cmu.edu
  19.  
  20. Archive-name: lisp-faq/part1
  21. Last-Modified: Thu Nov  5 19:30:40 1992 by Mark Kantrowitz
  22. Version: 1.27
  23.  
  24. ;;; ****************************************************************
  25. ;;; Answers to Frequently Asked Questions about Lisp ***************
  26. ;;; ****************************************************************
  27. ;;; Written by Mark Kantrowitz and Barry Margolin
  28. ;;; lisp-faq-1.text -- 60654 bytes
  29.  
  30. This post contains Part 1 of the Lisp FAQ.
  31.  
  32. If you think of questions that are appropriate for this FAQ, or would
  33. like to improve an answer, please send email to us at lisp-faq@think.com.
  34.  
  35. Note that the lisp-faq mailing list is for discussion of the content
  36. of the FAQ posting.  It is not the place to ask questions about Lisp;
  37. use either the common-lisp@ai.sri.com mailing list or the
  38. comp.lang.lisp newsgroup for that.  If a question appears frequently
  39. in one of those forums, it will get added to the FAQ list.
  40.  
  41. There are currently five parts to the Lisp FAQ:
  42.    1. Introductory Matter and Bibliography of Introductions and References
  43.    2. General Questions
  44.    3. Common Programming Pitfalls
  45.    4. Lisp/Scheme Implementations and Mailing Lists
  46.    5. CLOS and PCL Questions
  47.    6. FTP Archives and Resources
  48. Part 4 is cross-posted to the comp.lang.scheme newsgroup. Part 5 is
  49. cross-posted to the comp.lang.clos newsgroup.
  50.  
  51. Topics Covered (Part 1):
  52.  
  53.   [1-0]   What is the purpose of this newsgroup?
  54.   [1-1]   What documentation is available on Lisp? How can I learn Lisp?
  55.   [1-2]   How can I improve my Lisp programming style and coding efficiency?
  56.   [1-3]   Where can I learn about implementing Lisp interpreters and compilers?
  57.   [1-4]   What does CLOS, PCL, X3J13, CAR, CDR, ... mean? 
  58.   [1-5]   Where can I get a copy of the draft ANSI standard for Common Lisp?
  59.   [1-6]   Lisp Job Postings
  60.  
  61. Topics Covered (Part 2):
  62.  
  63.   [2-1]   Is there a GNU-Emacs interface to Lisp?
  64.   [2-3]   What is the equivalent of EXPLODE and IMPLODE in Common Lisp?
  65.   [2-4]   Is Lisp inherently slower than more conventional languages such as C?
  66.   [2-5]   Why does Common Lisp have "#'"?
  67.   [2-6]   How do I call non-Lisp functions from Lisp?
  68.   [2-7]   Can I call Lisp functions from other languages?
  69.   [2-8]   I want to call a function in a package that might not exist at
  70.           compile time. How do I do this?  
  71.   [2-9]   What is CDR-coding?
  72.   [2-10]  What is garbage collection?
  73.   [2-11]  How do I save an executable image of my loaded Lisp system?
  74.           How do I run a Unix command in my Lisp?
  75.           How do I get the current directory name from within a Lisp program?
  76.   [2-12]  I'm porting some code from a Symbolics Lisp machine to some
  77.           other platform, and there are strange characters in the code.
  78.           What do they mean?  
  79.   [2-13]  History: Where did Lisp come from?
  80.   [2-14]  How do I find the argument list of a function?
  81.           How do I get the function name from a function object?
  82.   [2-15]  How can I have two Lisp processes communicate via unix sockets?
  83.  
  84. Common Pitfalls (Part 3):
  85.  
  86.   [3-0]  Why does (READ-FROM-STRING "foobar" :START 3) return FOOBAR
  87.          instead of BAR?  
  88.   [3-1]  Why can't it deduce from (READ-FROM-STRING "foobar" :START 3)
  89.          that the intent is to specify the START keyword parameter
  90.          rather than the EOF-ERROR-P and EOF-VALUE optional parameters?   
  91.   [3-2]  Why can't I apply #'AND and #'OR?
  92.   [3-3]  I used a destructive function (e.g. DELETE, SORT), but it
  93.          didn't seem to work.  Why? 
  94.   [3-4]  After I NREVERSE a list, it's only one element long.  After I
  95.          SORT a list, it's missing things.  What happened? 
  96.   [3-5]  Why does (READ-LINE) return "" immediately instead of waiting
  97.          for me to type a line?  
  98.   [3-6]  I typed a form to the read-eval-print loop, but nothing happened. Why?
  99.   [3-7]  DEFMACRO doesn't seem to work.
  100.          When I compile my file, LISP warns me that my macros are undefined
  101.          functions, or complains "Attempt to call <function> which is 
  102.          defined as a macro.
  103.   [3-8]  Name conflict errors are driving me crazy! (EXPORT, packages)
  104.   [3-9]  Closures don't seem to work properly when referring to the
  105.          iteration variable in DOLIST, DOTIMES and DO.
  106.   [3-10] What is the difference between FUNCALL and APPLY?
  107.   [3-11] Miscellaneous things to consider when debugging code.
  108.   [3-12] When is it right to use EVAL?
  109.   [3-13] Why does my program's behavior change each time I use it?
  110.   [3-14] When producing formatted output in Lisp, where should you put the
  111.          newlines (e.g., before or after the line, FRESH-LINE vs TERPRI,
  112.          ~& vs ~% in FORMAT)?
  113.   [3-15] I'm using DO to do some iteration, but it doesn't terminate. 
  114.  
  115. Lisp/Scheme Implementations and Mailing Lists (Part 4):
  116.  
  117.   [4-0]   Free Lisp implementations.
  118.   [4-1]   Commercial Lisp implementations.
  119.   [4-2]   Free Scheme implementations.
  120.   [4-3]   Commercial Scheme implementations.
  121.   [4-4]   Other Commercial Lisp-like Language implementations.
  122.   [4-5]   Where can I get an implementation of Prolog in Lisp?
  123.   [4-6]   What is Dylan?
  124.   [4-7]   What Lisp-related discussion groups and mailing lists exist?
  125.   [4-8]   What are R4RS and IEEE P1178?
  126.   [4-9]   How do I do object-oriented programming in Scheme?
  127.  
  128. CLOS Questions (Part 5):
  129.  
  130.   [5-0]   What is CLOS (PCL) and where can I get it?
  131.           How do you pronounce CLOS?
  132.   [5-1]   What documentation is available about object-oriented
  133.           programming in Lisp?  
  134.   [5-2]   How I write a function that can access defstruct slots by
  135.           name?  I would like to write something like 
  136.           (STRUCTURE-SLOT <object> '<slot-name>).   
  137.   [5-3]   How can I list all the CLOS instances in a class?
  138.   [5-4]   How can I store data and CLOS instances (with possibly circular
  139.           references) on disk so that they may be retrieved at some later
  140.           time?
  141.   [5-5]   Given the name of a class, how can I get the names of its slots?
  142.  
  143. FTP Resources (Part 6):
  144.  
  145.   [6-0] General information about FTP Resources for Lisp and Scheme
  146.   [6-1] Repositories of Lisp Software
  147.   [6-2] Repositories of Scheme Software
  148.   [6-3] Publicly Redistributable Lisp Software
  149.   [6-4] Publicly Redistributable Scheme Software
  150.   [6-5] How can I use the X Window System or other GUIs from Lisp?
  151.   [6-6] Formatting code in LaTeX
  152.  
  153. Search for [#] to get to question number # quickly.
  154.  
  155.  
  156. Introduction:
  157.  
  158. Certain questions and topics come up frequently in the various network
  159. discussion groups devoted to and related to Lisp.  This file/article is
  160. an attempt to gather these questions and their answers into a convenient
  161. reference for Lisp programmers.  It (or a reference to it) is posted
  162. periodically.  The hope is that this will cut down on the user time and
  163. network bandwidth used to post, read and respond to the same questions
  164. over and over, as well as providing education by answering questions
  165. some readers may not even have thought to ask.
  166.  
  167. This is not a Lisp tutorial, nor is it an exhaustive list of all Lisp
  168. intricacies.  Lisp is a very powerful and expressive language, but with
  169. that power comes many complexities.  This list attempts to address the
  170. ones that average Lisp programmers are likely to encounter.  If you are
  171. new to Lisp, see the answer to the question "How can I learn Lisp?".
  172.  
  173. The latest version of this file is available via anonymous FTP from CMU
  174. and Thinking Machines: 
  175.  
  176.    To obtain the files from CMU, connect by anonymous ftp to any CMU CS
  177.    machine (e.g., ftp.cs.cmu.edu [128.2.206.173]), using username
  178.    "anonymous" and password "name@host". The files lisp-faq-1.text,
  179.    lisp-faq-2.text, lisp-faq-3.text, lisp-faq-4.text and lisp-faq-5.text
  180.    are located in the directory
  181.        /afs/cs.cmu.edu/user/mkant/Public/Lisp-Utilities/
  182.    [Note: You must cd to this directory in one atomic operation, as
  183.    some of the superior directories on the path are protected from
  184.    access by anonymous ftp.] If your site runs the Andrew File System,
  185.    you can just cp the files directly without bothering with FTP.
  186.  
  187.    To obtain the files from Thinking Machines, ftp them from ftp.think.com,
  188.    in the directory /public/think/lisp/. The file faq.text contains all the
  189.    parts of the FAQ in one file. In addition, specific versions of the FAQ
  190.    are available as faq-<version>.text.
  191.  
  192. Unless otherwise specified, the Lisp dialect referred to is Common Lisp,
  193. as defined by "Common Lisp: the Language" (aka "CLtL1") as well as
  194. corrections (but not enhancements) from "Common Lisp: the Language, 2nd
  195. Edition" (aka "CLtL2"), both by Guy L. Steele, Jr. and published by
  196. Digital Press. Note that CLtL2 is NOT an official specification for
  197. the language; ANSI Committee X3J13 is preparing such a specification.
  198. See question [1-5] for information on the status of the ANSI
  199. specification for Common Lisp. Enhancements such as CLOS, conditions,
  200. and the LOOP macro will be referred to separately.
  201.  
  202. ----------------------------------------------------------------
  203. [1-0] What is the purpose of this newsgroup?
  204.  
  205. The newsgroup comp.lang.lisp exists for general discussion of
  206. topics related to the programming language Lisp. For example, possible
  207. topics can include (but are not necessarily limited to):
  208.    announcements of Lisp books and products
  209.    discussion of programs and utilities written in Lisp
  210.    discussion of portability issues
  211.    questions about possible bugs in Lisp implementations
  212.    problems porting an implementation to some architecture
  213. Postings should be of general interest to the Lisp community. See also
  214. question [4-7].
  215.  
  216. Questions about object oriented programming in Lisp should be directed
  217. to the newsgroup comp.lang.clos. Similarly, questions about the
  218. programming language Scheme should be directed to the newsgroup
  219. comp.lang.scheme. Discussion of functional programming language issues
  220. should be directed to the newsgroup comp.lang.functional. Discussion
  221. of AI programs implemented in Lisp should sometimes be cross-posted to
  222. the newsgroup comp.ai.
  223.  
  224. ----------------------------------------------------------------
  225. [1-1] What documentation is available on Lisp? 
  226.       How can I learn Lisp?
  227.  
  228. There are several good Lisp introductions and tutorials:
  229.  
  230.    1. David S. Touretzky
  231.       "Common Lisp: A Gentle Introduction to Symbolic Computation"
  232.       Benjamin/Cummings Publishers, 1990. 384 pages.
  233.            Perhaps the best tutorial introduction to the language. It has
  234.            clear and correct explanations, and covers some fairly advanced
  235.            topics. The book is an updated Common Lisp version of the 1984
  236.            edition published by Harper and Row Publishers. 
  237.  
  238.            Three free Lisp educational tools which were used in the book --
  239.            Evaltrace, DTRACE and SDRAW -- are available by anonymous ftp from
  240.            b.gp.cs.cmu.edu:/usr/dst/public/{lisp,evaltrace}. Evaltrace is a
  241.            graphical notation for explaining how evaluation works and is
  242.            described in "Visualizing Evaluation in Applicative Languages" by
  243.            David S.  Touretzky and Peter Lee, CACM 45-59, October 1992. DTRACE
  244.            is a "detailed trace" which provides more information than the 
  245.            tracing tools provided with most Common Lisp implementations. SDRAW
  246.            is a program that draws cons cell structures both for X11 and ascii
  247.            terminals.
  248.  
  249.    2. Robert Wilensky
  250.       "Common LISPcraft"
  251.       W. W. Norton, 1986. 385 pages.
  252.  
  253.    3. Wade L. Hennessey 
  254.       "Common Lisp"
  255.       McGraw-Hill, 1989. 395 pages.
  256.            Fairly good, but jumps back and forth from the simple to the
  257.            complex rather quickly, with no clear progression in difficulty.
  258.  
  259.    4. Laurent Siklossy
  260.       "Let's Talk LISP"
  261.       Prentice-Hall, NJ, 1976. 237 pages.
  262.            Good introduction, but quite out of date.
  263.  
  264.    5. Stuart C. Shapiro
  265.       "Common Lisp: An Interactive Approach"
  266.       Computer Science Press/W.H. Freeman, New York, 1992.
  267.       ISBN 0-7167-8218-9
  268.  
  269. Other introductions to Lisp include:
  270.  
  271.    1. A. A. Berk.
  272.       "LISP, The Language of Artificial Intelligence"
  273.       Van Nostrand Reinhold, 1985. 160 pages.
  274.  
  275.    2. Paul Y. Gloess.
  276.       "An Alfred handy guide to Understanding LISP"
  277.       Alfred Publishers (Sherman Oaks, CA), 1982. 64 pages.
  278.  
  279.    3. Ward D. Maurer.
  280.       "The Programmer's Introduction to LISP"
  281.       American Elsevier, 1972. 112 pages.
  282.  
  283.    4. Hank Bromley and Richard Lamson.
  284.       "LISP Lore: A Guide to Programming the LISP Machine"
  285.       Kluwer Academic (Boston), 1987. 337 pages.
  286.  
  287.    5. Sharam Hekmatpour.
  288.       "Introduction to LISP and Symbol Manipulation"
  289.       Prentice Hall (New York), 1988. 303 pages.
  290.  
  291.    6. Deborah G. Tatar
  292.       "A programmer's guide to Common Lisp"
  293.       Digital Press, 1987. 327 pages. ISBN 0-932376-87-8.
  294.            Good introduction on Common Lisp.
  295.  
  296.    7. Timothy Koschmann
  297.       "The Common Lisp Companion"
  298.       John Wiley & Sons, 1990.
  299.        Targeted for those with some programming experience who wish to 
  300.        learn draft-ANSI Common Lisp, including CLOS and the CL condition 
  301.        system. Examples progress incrementally from simple numerical 
  302.        calculation all the way to a logic-programming extension to CL.
  303.   
  304. More advanced introductions to Lisp and its use in Artificial
  305. Intelligence include:
  306.  
  307.    1. Peter Norvig.
  308.       "Paradigms of AI Programming: Case Studies in Common Lisp"
  309.       Morgan Kaufmann, 1992. 946 pages. ISBN 1-55860-191-0.
  310.  
  311.         Provides an in-depth exposition of advanced AI programming techniques
  312.         and includes large-scale detailed examples. The book is the most
  313.         advanced AI/Common-Lisp programming text and reference currently
  314.         available, and hence is not for the complete novice.  It focuses on the
  315.         programming techniques necessary for building large AI systems,
  316.         including object-oriented programming, and has a strong performance
  317.         orientation.
  318.  
  319.         The text is marked by its use of "non-toy" examples to illustrate the
  320.         techniques. All of the examples are written in Common Lisp, and copies
  321.         of the source code are available by anonymous ftp from
  322.         unix.sri.com:pub/norvig and on disk in Macintosh or DOS format from
  323.         the publisher. Some of the techniques described include rule-based
  324.         pattern matching (GPS, Eliza, a subset of Macsyma, the Emycin expert
  325.         system shell), constraint propagation and backtracking (Waltz
  326.         line-labelling), alpha-beta search (Othello), natural language
  327.         processing (top-down, bottom-up and chart parsing), logic-programming
  328.         (unification and Prolog), interpreters and compilers for Scheme, and
  329.         object-oriented programming (CLOS).
  330.  
  331.         The examples are also used to illustrate good programming style and
  332.         efficiency. There is a guide to trouble-shooting and debugging Lisp
  333.         programs, a style guide, and a discussion of portability problems.
  334.         Some of the efficiency techniques described include memoization,
  335.         data indexing, compilation, delaying computation, proper use of
  336.         declarations, avoiding garbage collection, and choosing and using the
  337.         correct data structure.
  338.  
  339.         The book also serves as an advanced introduction to Common Lisp, with
  340.         sections on the Loop macro, CLOS and sequences, and some coverage of 
  341.         error handling, series, and the package facility.
  342.  
  343.    2. Eugene Charniak, Christopher K. Riesbeck, Drew V. McDermott
  344.       and James R. Meehan.
  345.       "Artificial Intelligence Programming", 2nd edition.
  346.       Lawrence Erlbaum Associates (Hillsdale, NJ), 1987. 533 pages.
  347.            Provides many nice code fragments, all of which are written
  348.            in Common Lisp. The first half of the book covers topics
  349.            like macros, the reader, data structures, control structures,
  350.            and defstructs. The second half of the book describes
  351.            programming techniques specific to AI, such as
  352.            discrimination nets, production systems, deductive database
  353.            retrieval, logic programming, and truth maintenance.
  354.  
  355.    3. Patrick H. Winston and Berthold K. P. Horn.
  356.       "LISP", 3rd edition.
  357.       Addison-Wesley (Reading, MA), 1989. 611 pages. ISBN 0-201-08319-1
  358.            Covers the basic concepts of the language, but also gives a lot
  359.            of detail about programming AI topics such as rule-based expert
  360.            systems, forward chaining, interpreting transition trees, 
  361.            compiling transition trees and finding patterns in images. Not 
  362.            a tutorial. Has many good examples.
  363.  
  364.    4. Rodney A. Brooks.
  365.       "Programming in Common Lisp"
  366.       Wiley, 1985. 303 pages.
  367.  
  368.    5. John R. Anderson, Albert T. Corbett, and Brian J. Reiser.
  369.       "Essential LISP"
  370.       Addison-Wesley (Reading, MA), 1987. 352 pages.
  371.            Concentrates on how to use Lisp with iteration and recursion.
  372.  
  373.    6. Robert D. Cameron and Anthony H. Dixon
  374.       "Symbolic Computing with Lisp"
  375.       Prentice-Hall, 1992, 326 pages. ISBN 0-13-877846-9.
  376.            The book is intended primarily as a third-year computer science
  377.            text. In terms of programming techniques, it emphasizes recursion
  378.            and induction, data abstraction, grammar-based definition of Lisp
  379.            data structures and functional programming style. It uses
  380.            two Lisp languages: 
  381.                 (1) a purely functional subset of Lisp called Small Lisp and
  382.                 (2) Common Lisp.
  383.            An MS-DOS interpreter for Small Lisp (including source) is
  384.            provided with the book.  It considers applications of Lisp
  385.            to formal symbolic data domains: algebraic expressions,
  386.            logical formulas, grammars and programming languages. 
  387.  
  388.    7. Hasemer and Domingue.
  389.       "Common Lisp Programming for Artificial Intelligence"
  390.       Addison-Wesley, 1989.
  391.  
  392.    8. Steven Tanimoto
  393.       "The Elements of Artificial Intelligence: An Introduction Using Lisp"
  394.       Computer Science Press, Rockville, MD, 1987, 530 pages.
  395.  
  396.    9. Patrick R. Harrison
  397.       "Common Lisp and Artificial Intelligence"
  398.       Prentice Hall, 1990. ISBN 0-13-155243
  399.  
  400.   10. Rajeev Sangal
  401.       "Programming Paradigms in Lisp"
  402.       McGraw-Hill, 1991. ISBN 0-07-054666-5.
  403.  
  404. General Lisp reference books include:
  405.  
  406.    1. Guy L. Steele
  407.       "Common Lisp: The Language" [CLtL1]
  408.       Digital Press, 1984. 465 pages. ISBN 0-932376-41-X.
  409.  
  410.    2. Guy L. Steele
  411.       "Common Lisp: The Language, 2nd Edition" [CLtL2]
  412.       Digital Press, 1990. 1029 pages. ISBN 1-55558-041-6.
  413.  
  414.    3. Franz Inc. 
  415.       "Common Lisp: The Reference"
  416.       Addison-Wesley, Reading, MA 1988. ISBN 0-201-11458-5
  417.            Entries on lisp functions in alphabetical order.
  418.  
  419.    4. K. Dybvig. 
  420.       "The Scheme programming language"
  421.       Prentice Hall, 1987.
  422.          Good reference for Scheme.
  423.  
  424. Lisp periodicals include:
  425.         
  426.    1. LISP Pointers.
  427.       Published by ACM SIGPLAN six times a year. Volume 1, Number 1
  428.       was April-May 1987. 
  429.  
  430.    2. LISP and Symbolic Computation, Kluwer Academic Press. Volume 1
  431.       was published in 1989. (jlz@lucid.com is the editor).  ISSN 0892-4635.
  432.       Subscriptions: Institutions $169; Individuals $80. Add $8 for
  433.       air mail. Kluwer Academic Publishers, PO Box 322, 3300 AH Dordrecht, 
  434.       The Netherlands, or Kluwer Academic Publishers, PO Box 358, Accord
  435.       Station, Hingham, MA 02018-0358. 
  436.  
  437.    3. Proceedings of the biannual ACM Lisp and Functional Programming
  438.       Conference. (First one was in 1980.)
  439.  
  440.    4. Proceedings of the annual Lisp Users and Vendors Conference.
  441.  
  442. Implementation-specific questions:
  443.  
  444.    1. Lucid. See the wizards.doc file that comes with the Lucid
  445.    release. It describes functions, macros, variables and constants that
  446.    are not official parts of the product and are not supported.
  447.    Constructs described in this file include: the interrupt facility, the
  448.    source file recording facility, the resource facility, multitasking,
  449.    writing your own streams, lisp pipes, i/o buffers, the compiler,
  450.    floating-point functions, memory management, debugger information, the
  451.    window tool kit, extensions to the editor, the foreign function
  452.    interface, clos information, delivery toolkit information, and Lucid
  453.    lisp training classes. The wizards.doc file also covers i/o
  454.    constructs, functions for dealing with DEFSTRUCT, functions and
  455.    constants for dealing with procedure objects, functions and constants
  456.    for dealing with code objects, function for mapping objects,
  457.    additional keyword argument to DISKSAVE, function used in the
  458.    implementation of arrays, function for monitor-specific behavior for a
  459.    process, additional keyword argument to RUN-PROGRAM, and load-time
  460.    evaluation.
  461.  
  462. Introductions to Scheme (Many books on Scheme are worth reading
  463. even if you use Common Lisp, because many of the issues are similar):
  464.  
  465.    1. Harold Abelson and Gerald Jay Sussman, with Julie Sussman.
  466.       "Structure and Interpretation of Computer Programs"
  467.       MIT Press (Cambridge, MA) and McGraw-Hill (New York), 1985.
  468.       542 pages. ISBN 0-262-01077-1
  469.            Starts off introductory, but rapidly gets into powerful
  470.            Lisp-particular constructs, such as using closures and
  471.            engines, building interpreters, compilers and
  472.            object-oriented systems.  
  473.  
  474.    2. Daniel P. Friedman and M. Felleisen.
  475.       "The Little LISPer"
  476.       MIT Press (Cambridge, MA), 1987. ISBN 0-262-56038-0.
  477.       Science Research Associates (Chicago), 3rd ed, 1989. 206 pages.
  478.            Good for a quick introduction. Uses Scheme instead of
  479.            Common Lisp.  (SRA edition uses a dialect of Scheme with
  480.            footnotes about translating to Scheme or Common Lisp. The
  481.            MIT Press edition is in Scheme without the footnotes.)
  482.  
  483.    3. George Springer and Daniel P. Friedman
  484.       "Scheme and the Art of Programming" 
  485.       MIT Press and McGraw Hill, 1990, 596 pages.
  486.            Introduces basic concepts of programming in Scheme. Also deals 
  487.            with object oriented programming, co-routining, continuations. 
  488.  
  489.    4. Wolfgang Kreutzer and Bruce McKenzie
  490.       "Programming for Artificial Intelligence: 
  491.        Methods, Tools and Applications"
  492.       Addison-Wesley (Reading, MA), 1990. 682 pages. 
  493.       ISBN 0-201-41621-2.
  494.            Discusses Scheme, Prolog, and Smalltalk, gives an overview of
  495.            the history and philosophy of AI, surveys three major
  496.            programming paradigms (procedural, declarative, and
  497.            object-oriented), and metaphors to AI programming.
  498.  
  499.    5. Smith
  500.       "Introduction to Scheme"
  501.        1988.
  502.            Focuses on PC Scheme.
  503.  
  504.    6. Michael Eisenberg 
  505.       "Programming in Scheme"
  506.       Scientific Press (Redwood City, CA), 1988. 304 pages.
  507.  
  508.    7. The Ken Dickey article, "The Scheme Programming Language", in
  509.       COMPUTER LANGUAGES magazine, and the Revised^4 Report on the
  510.       Algorithmic Language Scheme, both of which are available by anonymous
  511.       ftp from the scheme archive at nexus.yorku.ca.
  512.  
  513.    8. Two articles in BYTE Magazine, February 1988, by Abelson and
  514.       Sussman, and Clinger.
  515.  
  516.    9. The Info files from the MIT Scheme implementation.
  517.  
  518. Special Topics:
  519.  
  520.    Garbage Collection:
  521.  
  522.       Wilson, Paul R., "Uniprocessor Garbage Collection Techniques"
  523.       Proceedings of the 1992 International Workshop on Memory Management.
  524.       Surveys garbage collection techniques. Available by anonymous ftp from
  525.       cs.utexas.edu:pub/garbage/gcsurvey.ps. Contact wilson@cs.utexas.edu
  526.       for more info.
  527.  
  528. ----------------------------------------------------------------
  529. [1-2] How can I improve my Lisp programming style and coding efficiency?
  530.  
  531. There are several books about Lisp programming style, including:
  532.    
  533.    1. Molly M. Miller and Eric Benson
  534.       "Lisp Style and Design"
  535.       Digital Press, 1990. 214 pages. ISBN 1-55558-044-0.
  536.            How to write large Lisp programs and improve Lisp programming 
  537.            style. Uses the development of Lucid CL as an example. 
  538.  
  539.    2. Robin Jones, Clive Maynard, and Ian Stewart.
  540.       "The Art of Lisp Programming"
  541.       Springer-Verlag, 1989. 169 pages.
  542.  
  543.    3. W. Richard Stark.
  544.       "LISP, Lore, and Logic: an algebraic view of LISP
  545.        programming, foundations, and applications"
  546.       Springer-Verlag, 1990. 278 pages. ISBN 0-387-97072-X
  547.            Self-modifying code, self-reproducing programs, etc.
  548.  
  549.    4. CMU CL User's Manual, Chapter 7, (talks about writing
  550.       efficient code). It is available by anonymous ftp from any CMU CS 
  551.       machine (e.g., ftp.cs.cmu.edu [128.2.206.173]) as the file
  552.         /afs/cs.cmu.edu/project/clisp/docs/cmu-user/cmu-user.ps 
  553.       [when getting this file by anonymous ftp, one must cd to 
  554.       the directory in one atomic operation, as some of the superior
  555.       directories on the path are protected from access by anonymous ftp.]
  556.  
  557.    5. See also Norvig's book, SICP (Abelson & Sussman), SAP
  558.       (Springer and Friedman).
  559.  
  560.    6. Hallvard Tretteberg's Lisp Style Guide is available by anonymous
  561.       ftp in ftp.think.com:/public/think/lisp/style-guide.text. There is
  562.       a fair bit of overlap between Hallvard's style guide and the notes
  563.       below and in part 3 of this FAQ.
  564.  
  565. Here are some general suggestions/notes about improving Lisp
  566. programming style, readability, correctness and efficiency:
  567.  
  568.    General Programming Style Rules:
  569.  
  570.       - Write short functions, where each function provides a single,
  571.         well-defined operation. Small functions are easier to
  572.         read, write, test, debug, and understand.
  573.  
  574.       - Use descriptive variable and function names. If it isn't clear
  575.         from the name of a function or variable what its purpose is,
  576.         document it with a documentation string and a comment. In fact,
  577.         even if the purpose is evident from the name, it is still worth
  578.         documenting your code.
  579.  
  580.       - Don't write Pascal (or C) code in Lisp. Use the appropriate
  581.         predefined functions -- look in the index to CLtL2, or use the
  582.         APROPOS and DESCRIBE functions. Don't put a close parenthesis
  583.         on a line by itself -- this can really aggravate programmers
  584.         who grew up on Lisp. Lisp-oriented text editors include tools
  585.         for ensuring balanced parentheses and for moving across 
  586.         pairs of balanced parentheses.
  587.  
  588.       - Use proper indentation -- you should be able to understand
  589.         the structure of your definitions without noticing the parentheses. 
  590.  
  591.    The following functions often abused or misunderstood by novices. 
  592.    Think twice before using any of these functions.
  593.  
  594.       - EVAL. Novices almost always misuse EVAL. When experts use
  595.         EVAL, they often would be better off using APPLY, FUNCALL, or
  596.         SYMBOL-VALUE. Use of EVAL when defining a macro should set off
  597.         a warning bell -- macro definitions are already evaluated
  598.         during expansion. See also the answer to question 3-12.
  599.  
  600.       - PROGV. PROGV binds dynamic variables and is often misused in
  601.         conjunction with EVAL, which uses the dynamic environment. 
  602.         In general, avoid unnecessary use of special variables.
  603.         PROGV is mainly for writing interpreters for languages embedded
  604.         in Lisp. If you want to bind a list of values to a list of
  605.         lexical variables, use
  606.             (MULTIPLE-VALUE-BIND (..) (VALUES-LIST ..) ..)
  607.         or
  608.             (MULTIPLE-VALUE-SETQ (..) (VALUES-LIST ..))
  609.         instead. Most decent compilers can optimize this expression. 
  610.         However, use of this idiom is not to be encouraged unless absolutely
  611.         necessary.
  612.  
  613.       - CATCH and THROW. Often a named BLOCK and RETURN-FROM are
  614.         more appropriate. Use UNWIND-PROTECT when necessary.
  615.  
  616.       - Destructive operations, such as NCONC, SORT, DELETE,
  617.         RPLACA, and RPLACD, should be used carefully and sparingly.
  618.         In general, trust the garbage collector: allocate new
  619.         data structures when you need them.
  620.  
  621.    To improve the readability of your code,
  622.  
  623.       - Don't use any C{A,D}R functions with more than two
  624.         letters between the C and the R. When nested, they become
  625.         hard to read. If you have complex data structures, you
  626.         are often better off describing them with a DEFSTRUCT,
  627.         even if the type is LIST. If you must use C{A,D}R, try to
  628.         use destructuring-bind instead, or at least SECOND, THIRD,
  629.         NTH, NTHCDR, etc.
  630.  
  631.       - Use COND instead of IF and PROGN. In general, don't use PROGN if
  632.         there is a way to write the code within an implicit
  633.         PROGN. For example, 
  634.            (IF (FOO X)
  635.                (PROGN (PRINT "hi there") 23)
  636.                34)
  637.         should be written using COND instead.
  638.  
  639.       - Never use a 2-argument IF or a 3-argument IF with a second
  640.         argument of NIL unless you want to emphasize the return value;
  641.         use WHEN and UNLESS instead. You will want to emphasize the
  642.         return value when the IF clause is embedded within a SETQ,
  643.         such as (SETQ X (IF (EQ Y Z) 2 NIL)). If the second argument 
  644.         to IF is the same as the first, use OR instead: (OR P Q) rather
  645.         than (IF P P Q). Use UNLESS instead of (WHEN (NOT ..) ..)
  646.         but not instead of (WHEN (NULL ..) ..).
  647.  
  648.       - Use COND instead of nested IF statements. Be sure to check for
  649.         unreachable cases, and eliminate those cond-clauses.
  650.  
  651.       - Use backquote, rather than explicit calls to LIST, CONS, and
  652.         APPEND, whenever writing a form which produces a Lisp form, but
  653.         not as a general substitute for LIST, CONS and APPEND. LIST, 
  654.         CONS and APPEND usually allocate new storage, but lists produced
  655.         by backquote may involve destructive modification (e.g., ,.).
  656.  
  657.       - Make the names of special (global) variables begin and end
  658.         with an asterisk (*): (DEFVAR *GLOBAL-VARIABLE*)   
  659.         Some programmers will mark the beginning and end of an internal
  660.         global variable with a percent (%) or a period (.).
  661.         Make the names of constants begin and end with a plus (+):
  662.         (DEFCONSTANT +E+ 2.7182818)
  663.         This helps distinguish them from lexical variables. Some people
  664.         prefer to use macros to define constants, since this avoids
  665.         the problem of accidentally trying to bind a symbol declared
  666.         with defconstant.
  667.  
  668.       - If your program is built upon an underlying substrate which is
  669.         implementation-dependent, consider naming those functions and
  670.         macros in a way that visually identifies them, either by placing
  671.         them in their own package, or prepending a character like a %, ., 
  672.         or ! to the function name. Note that many programmers use the
  673.         $ as a macro character for slot access, so it should be avoided
  674.         unless you're using it for that purpose.
  675.  
  676.       - Don't use property lists. Instead, use an explicit hash table.
  677.         This helps avoid problems caused by the symbol being in the wrong
  678.         package, accidental reuse of property keys from other
  679.         programs, and allows you to customize the structure of the table. 
  680.  
  681.       - Use the most specific construct that does the job. This lets
  682.         readers of the code see what you intended when writing the code.
  683.         For example, don't use SETF if SETQ will do (e.g., for lexical
  684.         variables). Use the most specific predicate to test your conditions.
  685.         If you intend for a function to be a predicate, have it return T
  686.         for true, not just non-NIL. 
  687.  
  688.       - When NIL is used as an empty list, use () in your code. When NIL
  689.         is used as a boolean, use NIL. Similarly, use NULL to test for an
  690.         empty list, NOT to test a logical value. Use ENDP to test for the
  691.         end of a list, not NULL.
  692.  
  693.       - Don't use the &AUX lambda-list keyword. It is always clearer to
  694.         define local variables using LET or LET*.
  695.  
  696.       - When using RETURN and RETURN-FROM to exit from a block, don't
  697.         use (VALUES ..) when returning only one value, except if you
  698.         are using it to suppress extra multiple values from the first
  699.         argument. 
  700.  
  701.       - If you want a function to return no values (i.e., equivalent to
  702.         VOID in C), use (VALUES) to return zero values. This signals
  703.         to the reader that the function is used mainly for side-effects.
  704.  
  705.       - (VALUES (VALUES 1 2 3)) returns only the first value, 1.
  706.         You can use (VALUES (some-multiple-value-function ..)) to suppress
  707.         the extra multiple values from the function. Use MULTIPLE-VALUE-PROG1
  708.         instead of PROG1 when the multiple values are significant.
  709.  
  710.       - When using MULTIPLE-VALUE-BIND and DESTRUCTURING-BIND, don't rely
  711.         on the fact that NIL is used when values are missing. This is
  712.         an error in some implementations of DESTRUCTURING-BIND. Instead,
  713.         make sure that your function always returns the proper number of
  714.         values.
  715.  
  716.     Documentation:
  717.  
  718.       - Comment your code. Use three semicolons in the left margin before
  719.         the definition for major explanations. Use two semicolons that
  720.         float with the code to explain the routine that follows. Two
  721.         semicolons may also be used to explain the following line when the
  722.         comment is too long for the single semicolon treatment. Use
  723.         a single semicolon to the right of the code to explain a particular
  724.         line with a short comment. The number of semicolons used roughly
  725.         corresponds with the length of the comment. Put at least one blank
  726.         line before and after top-level expressions.
  727.  
  728.       - Include documentation strings in your code. This lets users
  729.         get help while running your program without having to resort to
  730.         the source code or printed documentation. 
  731.  
  732.    Issues related to macros:
  733.  
  734.       - Never use a macro instead of a function for efficiency reasons.
  735.         Declaim the function as inline -- for example, 
  736.           (DECLAIM (INLINE ..))
  737.         This is *not* a magic bullet -- be forewarned that inline
  738.         expansions can often increase the code size dramatically. INLINE
  739.         should be used only for short functions where the tradeoff is
  740.         likely to be worthwhile: inner loops, types that the compiler
  741.         might do something smart with, and so on.
  742.  
  743.       - When defining a macro that provides an implicit PROGN, use the
  744.         &BODY lambda-list keyword instead of &REST.
  745.  
  746.       - Use gensyms for bindings within a macro, unless the macro lets
  747.         the user explicitly specify the variable. For example:
  748.             (defmacro foo ((iter-var list) body-form &body body)
  749.               (let ((result (gensym "RESULT")))
  750.                 `(let ((,result nil))
  751.                    (dolist (,iter-var ,list ,result)
  752.                      (setq ,result ,body-form)
  753.                      (when ,result
  754.                         ,@body)))))        
  755.         This avoids errors caused by collisions during macro expansion
  756.         between variable names used in the macro definition and in the
  757.         supplied body.
  758.  
  759.       - Use a DO- prefix in the name of a macro that does some kind of
  760.         iteration, WITH- when the macro establishes bindings, and
  761.         DEFINE- or DEF- when the macro creates some definitions. Don't
  762.         use the prefix MAP- in macro names, only in function names.
  763.  
  764.       - Don't create a new iteration macro when an existing function
  765.         or macro will do.
  766.  
  767.       - Don't define a macro where a function definition will work just
  768.         as well -- remember, you can FUNCALL or MAPCAR a function but 
  769.         not a macro.
  770.  
  771.       - The LOOP and SERIES macros generate efficient code. If you're
  772.         writing a new iteration macro, consider learning to use one
  773.         of them instead.
  774.   
  775.    File Modularization:
  776.  
  777.       - If your program involves macros that are used in more than one
  778.     file, it is generally a good idea to put such macros in a separate
  779.     file that gets loaded before the other files. The same things applies
  780.     to primitive functions. If a macro is complicated, the code that
  781.     defines the macro should be put into a file by itself. In general, if
  782.     a set of definitions form a cohesive and "independent" whole, they
  783.     should be put in a file by themselves, and maybe even in their own
  784.     package. It isn't unusual for a large Lisp program to have files named
  785.     "site-dependent-code", "primitives.lisp", and "macros.lisp". If a file
  786.     contains primarily macros, put "-macros" in the name of the file.
  787.  
  788.    Stylistic preferences:
  789.  
  790.       - Use (SETF (CAR ..) ..) and (SETF (CDR ..) ..) in preference to
  791.         RPLACA and RPLACD. Likewise (SETF (GET ..) ..) instead of PUT.
  792.  
  793.       - Use INCF, DECF, PUSH and POP instead instead of the corresponding
  794.         SETF forms.
  795.  
  796.       - Many programmers religiously avoid using CATCH, THROW, BLOCK,
  797.         PROG, GO and TAGBODY.  Tags and go-forms should only be necessary
  798.         to create extremely unusual and complicated iteration constructs. In
  799.         almost every circumstance, a ready-made iteration construct or
  800.         recursive implementation is more appropriate.
  801.  
  802.       - Don't use LET* where LET will do. Don't use LABELS where FLET
  803.         will do. Don't use DO* where DO will do.
  804.  
  805.       - Don't use DO where DOTIMES or DOLIST will do.
  806.  
  807.       - If you like using MAPCAR instead of DO/DOLIST, use MAPC when
  808.         no result is needed -- it's more efficient, since it doesn't
  809.         cons up a list. If a single cumulative value is required, use
  810.         REDUCE. If you are seeking a particular element, use FIND,
  811.         POSITION, or MEMBER.
  812.  
  813.       - If using REMOVE and DELETE to filter a sequence, don't use the
  814.         :test-not keyword or the REMOVE-IF-NOT or DELETE-IF-NOT functions.
  815.         Use COMPLEMENT to complement the predicate and the REMOVE-IF
  816.         or DELETE-IF functions instead.
  817.  
  818.       - Use complex numbers to represent points in a plane.
  819.  
  820.       - Don't use lists where vectors are more appropriate. Accessing the
  821.         nth element of a vector is faster than finding the nth element
  822.         of a list, since the latter requires pointer chasing while the
  823.         former requires simple addition. Vectors also take up less space
  824.         than lists. Use adjustable vectors with fill-pointers to
  825.         implement a stack, instead of a list -- using a list continually
  826.         conses and then throws away the conses.
  827.  
  828.       - When adding an entry to an association list, use ACONS, not
  829.         two calls to CONS. This makes it clear that you're using an alist.
  830.  
  831.       - If your association list has more than about 10 entries in it,
  832.         consider using a hash table. Hash tables are often more efficient.
  833.  
  834.       - When you don't need the full power of CLOS, consider using
  835.         structures instead. They are often faster, take up less space, and
  836.         easier to use.
  837.  
  838.       - Use PRINT-UNREADABLE-OBJECT when writing a print-function.
  839.  
  840.       - Use WITH-OPEN-FILE instead of OPEN and CLOSE.
  841.  
  842.       - When a HANDLER-CASE clause is executed, the stack has already
  843.         unwound, so dynamic bindings that existed when the error
  844.         occured may no longer exist when the handler is run. Use
  845.         HANDLER-BIND if you need this. 
  846.  
  847.       - When using CASE and TYPECASE forms, if you intend for the form
  848.         to return NIL when all cases fail, include an explicit OTHERWISE
  849.         clause. If it would be an error to return NIL when all cases
  850.         fail, use ECASE, CCASE, ETYPECASE or CTYPECASE instead.
  851.  
  852.       - Use local variables in preference to global variables whenever
  853.         possible. Do not use global variables in lieu of parameter passing.
  854.         Global variables can be used in the following circumstances:
  855.           *  When one function needs to affect the operation of
  856.              another, but the second function isn't called by the first.
  857.              (For example, *load-pathname* and *break-on-warnings*.)
  858.           *  When a called function needs to affect the current or future
  859.              operation of the caller, but it doesn't make sense to accomplish
  860.              this by returning multiple values.
  861.           *  To provide hooks into the mechanisms of the program.
  862.              (For example, *evalhook*, *, /, and +.)
  863.           *  Parameters which, when their value is changed, represent a
  864.              major change to the program.
  865.              (For example, *print-level* and *print-readably*.)
  866.           *  For state that persists between invocations of the program.
  867.              Also, for state which is used by more than one major program.
  868.              (For example, *package*, *readtable*, *gensym-counter*.)
  869.           *  To provide convenient information to the user.
  870.              (For example, *version* and *features*.)
  871.           *  To provide customizable defaults. 
  872.              (For example, *default-pathname-defaults*.)
  873.           *  When a value affects major portions of a program, and passing
  874.              this value around would be extremely awkward. (The example
  875.              here is output and input streams for a program. Even when
  876.              the program passes the stream around as an argument, if you
  877.              want to redirect all output from the program to a different
  878.              stream, it is much easier to just rebind the global variable.)
  879.  
  880.    Correctness and efficiency issues:
  881.  
  882.       - In CLtL2, IN-PACKAGE does not evaluate its argument. Use defpackage
  883.         to define a package and declare the external (exported)
  884.         symbols from the package. 
  885.  
  886.       - The ARRAY-TOTAL-SIZE-LIMIT may be as small as 1024, and the
  887.         CALL-ARGUMENTS-LIMIT may be as small as 50. 
  888.  
  889.       - Novices often mistakenly quote the conditions of a CASE form.
  890.         For example, (case x ('a 3) ..) is incorrect. It would return
  891.         3 if x were the symbol QUOTE. Use (case x (a 3) ..) instead.
  892.  
  893.       - Avoid using APPLY to flatten lists. (apply #'append list-of-lists)
  894.         is compiled into a function call, and can run into problems with
  895.         the CALL-ARGUMENTS-LIMIT. Use REDUCE or MAPCAR instead:
  896.            (reduce #'append list-of-lists :from-end t)
  897.            (mapcan #'copy-list list-of-lists)
  898.         The second will often be more efficient (see note below about choosing
  899.         the right algorithm). Beware of calls like (apply f (mapcar ..)).
  900.  
  901.       - NTH must cdr down the list to reach the elements you are
  902.         interested in. If you don't need the structural flexibility of
  903.         lists, try using vectors and the ELT function instead.
  904.  
  905.       - Don't use quoted constants where you might later destructively
  906.         modify them. For example, instead of writing '(c d) in
  907.            (defun foo ()
  908.              (let ((var '(c d)))
  909.                ..))
  910.         write (list 'c 'd) instead. Using a quote here can lead to
  911.         unexpected results later. If you later destructively modify the 
  912.         value of var, this is self-modifying code! Some Lisp compilers
  913.         will complain about this, since they like to make constants
  914.         read-only. Modifying constants has undefined results in ANSI CL.
  915.         See also the answer to question [3-13].
  916.  
  917.         Similarly, beware of shared list structure arising from the use
  918.         of backquote. Any sublist in a backquoted expression that doesn't
  919.         contain any commas can share with the original source structure.
  920.  
  921.       - Don't proclaim unsafe optimizations, such as
  922.            (proclaim '(optimize (safety 0) (speed 3) (space 1))) 
  923.         since this yields a global effect. Instead, add the
  924.         optimizations as local declarations to small pieces of
  925.         well-tested, performance-critical code:
  926.            (defun well-tested-function ()
  927.               (declare (optimize (safety 0) (speed 3) (space 1)))
  928.              ..)
  929.         Such optimizations can remove run-time type-checking; type-checking
  930.         is necessary unless you've very carefully checked your code
  931.         and added all the appropriate type declarations.
  932.  
  933.       - Some programmers feel that you shouldn't add declarations to
  934.         code until it is fully debugged, because incorrect
  935.         declarations can be an annoying source of errors. They recommend
  936.         using CHECK-TYPE liberally instead while you are developing the code.
  937.         On the other hand, if you add declarations to tell the
  938.         compiler what you think your code is doing, the compiler can
  939.         then tell you when your assumptions are incorrect.
  940.         Declarations also make it easier for another programmer to read
  941.         your code. 
  942.  
  943.       - Don't change the compiler optimization with an OPTIMIZE
  944.         proclamation or declaration until the code is fully debugged
  945.         and profiled.  When first writing code you should say 
  946.         (declare (optimize (safety 3))) regardless of the speed setting.
  947.  
  948.       - Depending on the optimization level of the compiler, type
  949.         declarations are interpreted either as (1) a guarantee from
  950.         you that the variable is always bound to values of that type,
  951.         or (2) a desire that the compiler check that the variable is
  952.         always bound to values of that type. Use CHECK-TYPE if (2) is
  953.         your intention.
  954.  
  955.       - If you get warnings about unused variables, add IGNORE
  956.         declarations if appropriate or fix the problem. Letting such
  957.         warnings stand is a sloppy coding practice.
  958.  
  959.    To produce efficient code,
  960.  
  961.       - choose the right algorithm. For example, consider seven possible
  962.         implementations of COPY-LIST:
  963.  
  964.            (defun copy-list (list)
  965.              (let ((result nil))
  966.                (dolist (item list result)
  967.                  (setf result (append result (list item))))))
  968.  
  969.            (defun copy-list (list)
  970.              (let ((result nil))
  971.                (dolist (item list (nreverse result))
  972.                  (push item result))))
  973.  
  974.            (defun copy-list (list)
  975.              (mapcar #'identity list))
  976.  
  977.            (defun copy-list (list)
  978.              (let ((result (make-list (length list))))
  979.                (do ((original list (cdr original))
  980.                     (new result (cdr new)))
  981.                    ((null original) result)
  982.                  (setf (car new) (car original)))))
  983.  
  984.            (defun copy-list (list)
  985.              (when list
  986.                (let* ((result (list (car list)))
  987.                       (tail-ptr result))
  988.                  (dolist (item (cdr list) result)
  989.                    (setf (cdr tail-ptr) (list item))
  990.                    (setf tail-ptr (cdr tail-ptr))))))
  991.         
  992.             (defun copy-list (list)
  993.               (loop for item in list collect item))
  994.  
  995.             (defun copy-list (list)
  996.               (if (consp list) 
  997.                   (cons (car list)
  998.                         (copy-list (cdr list)))
  999.                   list))
  1000.  
  1001.         The first uses APPEND to tack the elements onto the end of the list.
  1002.         Since APPEND must traverse the entire partial list at each step, this
  1003.         yields a quadratic running time for the algorithm.  The second
  1004.         implementation improves on this by iterating down the list twice; once
  1005.         to build up the list in reverse order, and the second time to reverse
  1006.         it. The efficiency of the third depends on the Lisp implementation,
  1007.         but it is usually similar to the second, as is the fourth.  The fifth
  1008.         algorithm, however, iterates down the list only once. It avoids the
  1009.         extra work by keeping a pointer (reference) to the last cons of the 
  1010.         list and RPLACDing onto the end of that. Use of the fifth algorithm 
  1011.         may yield a speedup. Note that this contradicts the earlier dictum to
  1012.         avoid destructive functions. To make more efficient code one might
  1013.         selectively introduce destructive operations in critical sections of
  1014.         code. Nevertheless, the fifth implementation may be less efficient in
  1015.         Lisps with cdr-coding, since it is more expensive to RPLACD cdr-coded
  1016.         lists. Depending on the implementation of nreverse, however,
  1017.         the fifth and second implementations may be doing the same
  1018.         amount of work. The sixth example uses the Loop macro, which usually
  1019.         expands into code similar to the third. The seventh example copies
  1020.         dotted lists, and runs in linear time. It's equivalent to the other
  1021.         linear-time examples in a lisp that is properly tail-recursive. 
  1022.  
  1023.       - use type declarations liberally in time-critical code, but
  1024.         only if you are a seasoned Lisp programmer. Appropriate type
  1025.         declarations help the compiler generate more specific and
  1026.         optimized code. It also lets the reader know what assumptions
  1027.         were made. For example, if you only use fixnum arithmetic,
  1028.         adding declarations can lead to a significant speedup. If you
  1029.         are a novice Lisp programmer, you should use type declarations
  1030.         sparingly, as there may be no checking to see if the
  1031.         declarations are correct. Wrong declarations can lead to errors
  1032.         in otherwise correct code, and can limit the reuse of code
  1033.         in other contexts. Depending on the Lisp compiler, it may also
  1034.         be necessary to declare the type of results using THE, since
  1035.         some compilers don't deduce the result type from the inputs.
  1036.  
  1037.       - check the code produced by the compiler by using the
  1038.         disassemble function
  1039.  
  1040. ----------------------------------------------------------------
  1041. [1-3] Where can I learn about implementing Lisp interpreters and compilers?
  1042.  
  1043. Books about Lisp implementation include:
  1044.  
  1045.    1. John Allen
  1046.       "Anatomy of Lisp"
  1047.       McGraw-Hill, 1978. 446 pages. ISBN 0-07-001115-X
  1048.  
  1049.    2. Samuel Kamin
  1050.       "Programming Languages, An Interpreter-Based Approach"
  1051.       Addison-Wesley. ISBN 0-201-06824-9
  1052.            Includes sources to several interpreters for Lisp-like
  1053.            languages, and a pointer to sources via anonymous ftp.
  1054.  
  1055.    3. Sharam Hekmatpour
  1056.       "Lisp: A Portable Implementation"
  1057.       Prentice Hall, 1985. ISBN 0-13-537490-X.
  1058.            Describes a portable implementation of a small dynamic
  1059.            Lisp interpreter (including C source code). 
  1060.  
  1061.    4. Peter Henderson
  1062.       "Functional Programming: Application and Implementation"
  1063.       Prentice-Hall (Englewood Cliffs, NJ), 1980. 355 pages.
  1064.  
  1065.    5. Peter M. Kogge
  1066.       "The Architecture of Symbolic Computers"
  1067.       McGraw-Hill, 1991. ISBN 0-07-035596-7.
  1068.            Includes sections on memory management, the SECD and
  1069.            Warren Abstract Machines, and overviews of the various
  1070.            Lisp Machine architectures.
  1071.    
  1072.    6. Daniel P. Friedman, Mitchell Wand, and Christopher T. Haynes
  1073.       "Essentials of Programming Languages"
  1074.       MIT Press, 1992, 536 pages. ISBN 0-262-06145-7.
  1075.            Teaches fundamental concepts of programming language
  1076.            design by using small interpreters as examples. Covers
  1077.            most of the features of Scheme. Includes a discussion
  1078.            of parameter passing techniques, object oriented languages,
  1079.            and techniques for transforming interpreters to allow
  1080.            their implementation in terms of any low-level language.
  1081.            Also discusses scanners, parsers, and the derivation of
  1082.            a compiler and virtual machine from an interpreter.
  1083.            Source files available by anonymous ftp from cs.indiana.edu
  1084.            in the directory /pub/eopl (129.79.254.191).
  1085.  
  1086.    7. Also see the proceedings of the biannual ACM Lisp and
  1087.       Functional Programming conferences, and the implementation
  1088.       notes for CMU Common Lisp.
  1089. ----------------------------------------------------------------
  1090. [1-4]  What does CLOS, PCL, X3J13, CAR, CDR, ... mean? 
  1091.  
  1092. Glossary of acronyms:
  1093.    CAR             Originally meant "Contents of Address portion of Register",
  1094.                    which is what CAR actually did on the IBM 704.
  1095.    CDR             Originally meant "Contents of Decrement portion of 
  1096.                    Register", which is what CDR actually did
  1097.                    on the IBM 704. Pronounced "Cudder".
  1098.    LISP            Originally from "LISt Processing"
  1099.    GUI             Graphical User Interface
  1100.    CLOS            Common Lisp Object System. The object oriented
  1101.                    programming standard for Common Lisp. Based on
  1102.                    Symbolics FLAVORS and Xerox LOOPS, among others.
  1103.                    Pronounced either as "See-Loss" or "Closs". See also PCL.
  1104.    PCL             Portable Common Loops. A portable CLOS implementation.
  1105.                    Available by anonymous ftp from parcftp.xerox.com:pcl/.
  1106.    LOOPS           Lisp Object Oriented Programming System. A predecessor
  1107.                    to CLOS on Xerox Lisp machines.
  1108.    X3J13           Subcommittee of the ANSI committee X3 which is
  1109.                    working on the ANSI Standardization of Common Lisp.
  1110.    ANSI            American National Standards Institute
  1111.    CL              Common Lisp
  1112.    SC22/WG16       The full name is ISO/IEC JTC 1/SC 22/WG 16. It stands
  1113.                    for International Organization for
  1114.                    Standardization/International Electronics(?)  
  1115.                    Congress(?) Joint Technical Committee 1, Subcommittee 22,
  1116.                    Working Group 16.  This long-winded name is the ISO
  1117.                    working group working on an international Lisp standard,
  1118.                    (i.e., the ISO analogue to X3J13).
  1119.    CLtL1           First edition of Guy Steele's book, 
  1120.                    "Common Lisp the Language". 
  1121.    CLtL2           Second edition of Guy Steele's book,
  1122.                    "Common Lisp the Language". 
  1123.  
  1124.    SICP            Abelson and Sussman's book "Structure and
  1125.                    Interpretation of Computer Programs".
  1126.    SCOOPS          An experimental object-oriented programming
  1127.                    language for Scheme.
  1128.    R3RS            Revised^3 Report on the Algorithmic Language Scheme.
  1129.    R4RS            Revised^4 Report on the Algorithmic Language Scheme.
  1130. ----------------------------------------------------------------
  1131. [1-5]   Where can I get a copy of the draft ANSI standard for Common Lisp?
  1132.  
  1133. The draft proposed American National Standard for Common Lisp is under
  1134. public review until November 23, 1992. 
  1135.  
  1136. Hard copies of the draft may be purchased from Global Engineering
  1137. Documents, Inc., 2805 McGaw Avenue, Irvine, CA  92714, 1-800-854-7179,
  1138. 714-261-1455 for a single copy price of $80 ($104 international).
  1139. Copies of the TeX sources and Unix-compressed DVI files may be
  1140. obtained by anonymous FTP from parcftp.xerox.com in the directory
  1141. /pub/cl/document/*. The file Reviewer-Notes.text should be read before
  1142. ftp'ing the other files.
  1143.  
  1144. There is no mechanism for submitting Public Review comments by e-mail.
  1145. Comments on the draft must be submitted in hard copy format BOTH to X3
  1146. Secretariat, Attn: Lynn Barra, 1250 Eye Street NW, Suite 200,
  1147. Washington, DC 20005-3922 AND to American National Standards Institute,
  1148. Attn: BSR Center, 11 West 42nd St. 13th Floor, New York, NY 10036.
  1149.  
  1150. ----------------------------------------------------------------
  1151. [1-6]   Lisp Job Postings
  1152.  
  1153. The LISP-JOBS mailing list exists to help programmers find Lisp
  1154. programming positions, and to help companies with Lisp programming
  1155. positions find capable Lisp programmers. (Lisp here means Lisp-like
  1156. languages, including Scheme.)
  1157.  
  1158. Material appropriate for the list includes Lisp job announcements and
  1159. resumes from Lisp programmers (which should be sent only once) should
  1160. be sent to lisp-jobs@amc.com.  Administrative requests (e.g., to be
  1161. added to the list) should be sent to lisp-jobs-request@amc.com.
  1162.  
  1163. ----------------------------------------------------------------
  1164.      
  1165. ;;; ********************************
  1166. ;;; Change Log *********************
  1167. ;;; ********************************
  1168. ;;; Date      Who     Ver   Reason
  1169. ;;; ------------------------------------------------------------
  1170. ;;;  7-FEB-92 mk      1.0   Initial release.
  1171. ;;; 10-FEB-92 mk      1.1   Pre-release corrections and additions.
  1172. ;;; 10-FEB-92 mk      1.11  Minor changes from Arun Welch, Mitch Marks, 
  1173. ;;;                         Mike Meyer, Matthias Felleisen, and John Gateley.
  1174. ;;; 11-FEB-92 mk      1.12  Corrections by John Carroll, Jason Trenouth, Joel
  1175. ;;;                         Riedesel, David Neves, Lawrence Mayka and
  1176. ;;;                         Bruce Miller.
  1177. ;;; 13-FEB-92 mk      1.13  Renumbering. Split into 3 files. Some more FAQs.
  1178. ;;; 23-MAR-92 mk      1.14  Updated various FTP entries, bug in EXPLODE.
  1179. ;;;                         Updated harlequin entry.
  1180. ;;; 25-MAR-92 mk      1.15  Added question [2-18]: saving data and CLOS
  1181. ;;;                         instances to disk for later retrieval.
  1182. ;;;  1-MAY-92 mk      1.17  Added entry for Feel to question [1-5]. Updated CMU
  1183. ;;;                         ftp machines to point to ftp.cs.cmu.edu. Fixed CMU
  1184. ;;;                         CL entry to be approximately version independent.
  1185. ;;;                         Revised entry on Garnet. uunet.uu.net -> ftp.uu.net
  1186. ;;; 12-MAY-92 mk      1.18  Split questions 1-5, 1-6, and 1-7 into part 4,
  1187. ;;;                         which is now cross-posted to comp.lang.scheme, and
  1188. ;;;                         questions 1-8, 2-3, 2-9 and 2-18 into part 5 which
  1189. ;;;                         is now cross-posted to comp.lang.clos.
  1190. ;;;                         Added detail to Norvig entry in 1-1.
  1191. ;;;                         Updated entries for several Lisp implementations.
  1192. ;;; 26-MAY-92 mk      1.19  Changed 5-2 on the basis of comments by Jeff Greif.
  1193. ;;; 29-MAY-92 mk      1.20  Added question [2-17] about lisp sockets.
  1194. ;;; 16-JUN-92 mk      1.21  Moved the question about object oriented
  1195. ;;;                         programming references to part 5 of the FAQ.
  1196. ;;;                         Entry on Dylan. Addition to MIT Scheme entry
  1197. ;;;                         regarding Schematik.
  1198. ;;; 22-JUN-92 mk            Updated SOAR entry.
  1199. ;;; 24-JUN-92 mk            Fixed MCL entry to note that CLIM is available 
  1200. ;;;                         from ILA, not via Apple.
  1201. ;;; 25-JUN-92 mk      1.22  Added question [2-18].
  1202. ;;; 17-JUL-92 mk            Added entry on PSD (Portable Scheme Debugger).
  1203. ;;; 20-JUL-92 mk            Updated entry on T3.1
  1204. ;;; 30-JUL-92 mk            Added entry on XIT to question 2-2.
  1205. ;;;  3-AUG-92 mk            Updated PC-Scheme entry (bought by Ibuki).
  1206. ;;;  6-AUG-92 mk      1.23  Merged in Jeff Dalton's pitfalls list.
  1207. ;;; 19-AUG-92 mk            Added entry on FOCL. Move three questions from 
  1208. ;;;                         part 2 to part 3, to keep part 2 under 64k.
  1209. ;;; 26-AUG-92 mk            Added some items from Hallvard Tretteberg's
  1210. ;;;                         Lisp style guide.
  1211. ;;; 31-AUG-92 mk      1.24  Updated entries for CMU CL and SIOD.
  1212. ;;;  8-SEP-92 mk            Added entry on VSCM to part 4. Added entry on
  1213. ;;;                         Pixie Scheme, Help, and Le-Lisp.
  1214. ;;; 14-SEP-92 mk            Fixed Symbolics entry. Added entry on CLIM-library.
  1215. ;;; 15-SEP-92 mk            Updated MIT C-Scheme entry.
  1216. ;;; 17-SEP-92 mk            Added entry on Lisp-Jobs. Fixed Le-Lisp entry.
  1217. ;;;                         Added 3-15.
  1218. ;;; 23-SEP-92 mk            Added entry on COLAB to ftp resources.
  1219. ;;;                         Added entry on WCL to Part 4.
  1220. ;;; 30-SEP-92 mk            Added entry on Dr. Dobb's lisp-style C extensions.
  1221. ;;;                         Updated entry on Friedman/Wand/Haynes' book.
  1222. ;;;  9-OCT-92 mk      1.25  Updated Chez Scheme entry.
  1223. ;;;                         Added entry on extracting the function name from
  1224. ;;;                         the function object, provided by Kerry Koitzsch.
  1225. ;;; 14-OCT-92 mk      1.26  Split off the ftp resources question from Part 2
  1226. ;;;                         into its own file, now labels Part 6.
  1227. ;;;                         Broke up the question into smaller pieces
  1228. ;;;                         and reorganized it too. Reorganized Part 4.
  1229. ;;; 20-OCT-92 mk            Added description of Koschmann text,
  1230. ;;;                         thanks to L. Mayka.
  1231. ;;; 27-OCT-92 mk      1.27  Added question 6-6 about formatting code in LaTeX.
  1232. ;;;  3-NOV-92 mk            Added comment on file modularization to 1-2.
  1233. ;;;                         Added note on the CLOS code repository to
  1234. ;;;                         6-1.
  1235. ;;;  5-NOV-92 mk            Added info on Lucid benchmark programs in the 
  1236. ;;;                         goodies/ directory. Also the Lucid
  1237. ;;;                         wizards.doc file.
  1238. ;;; 11-NOV-92 mk    Added entry on Karlsruhe CLISP to 4-0.
  1239. ;;; ------------------------------------------------------------
  1240.  
  1241. ;;; *EOF*
  1242.