home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Information / Languages / Lisp / lisp-faq⁄part1 next >
Encoding:
Internet Message Format  |  1994-12-08  |  75.8 KB  |  [TEXT/R*ch]

  1. Path: bloom-beacon.mit.edu!uhog.mit.edu!nntp.club.cc.cmu.edu!cantaloupe.srv.cs.cmu.edu!mkant
  2. From: mkant+@cs.cmu.edu (Mark Kantrowitz)
  3. Newsgroups: comp.lang.lisp,news.answers,comp.answers
  4. Subject: FAQ: Lisp Frequently Asked Questions 1/7 [Monthly posting]
  5. Supersedes: <LISP_1_782031621@CS.CMU.EDU>
  6. Followup-To: poster
  7. Date: 13 Nov 1994 08:00:44 GMT
  8. Organization: Carnegie-Mellon University, School of Computer Science
  9. Lines: 1571
  10. Approved: news-answers-request@MIT.Edu
  11. Distribution: world
  12. Expires: 25 Dec 1994 08:00:25 GMT
  13. Message-ID: <LISP_1_784713625@CS.CMU.EDU>
  14. Reply-To: ai+lisp-faq@cs.cmu.edu
  15. NNTP-Posting-Host: glinda.oz.cs.cmu.edu
  16. Summary: Introductory Matter and Bibliography of Introductions and References
  17. Xref: bloom-beacon.mit.edu comp.lang.lisp:7451 news.answers:29280 comp.answers:8315
  18.  
  19. Archive-name: lisp-faq/part1
  20. Last-Modified: Fri Nov 11 17:20:12 1994 by Mark Kantrowitz
  21. Version: 1.51
  22. Maintainer: Mark Kantrowitz and Barry Margolin <ai+lisp-faq@cs.cmu.edu>
  23. URL: http://www.cs.cmu.edu:8001/Web/Groups/AI/html/faqs/lang/lisp/top.html
  24. Size: 77094 bytes, 1579 lines
  25.  
  26. ;;; ****************************************************************
  27. ;;; Answers to Frequently Asked Questions about Lisp ***************
  28. ;;; ****************************************************************
  29. ;;; Written by Mark Kantrowitz and Barry Margolin
  30. ;;; lisp_1.faq 
  31.  
  32. This post contains Part 1 of the Lisp FAQ.
  33.  
  34. If you think of questions that are appropriate for this FAQ, or would
  35. like to improve an answer, please send email to us at ai+lisp-faq@cs.cmu.edu.
  36.  
  37. Note that the lisp-faq mailing list is for discussion of the content
  38. of the FAQ posting only.  It is not the place to ask questions about Lisp;
  39. use either the common-lisp@ai.sri.com mailing list or the
  40. comp.lang.lisp newsgroup for that.  If a question appears frequently
  41. in one of those forums, it will get added to the FAQ list.
  42.  
  43. *** Copyright:
  44.  
  45. Copyright (c) 1992-94 by Mark Kantrowitz and Barry Margolin. 
  46. All rights reserved. 
  47.  
  48. This FAQ may be freely redistributed in its entirety without
  49. modification provided that this copyright notice is not removed.  It
  50. may not be sold for profit or incorporated in commercial documents
  51. (e.g., published for sale on CD-ROM, floppy disks, books, magazines,
  52. or other print form) without the prior written permission of the
  53. copyright holder.  Permission is expressly granted for this document
  54. to be made available for file transfer from installations offering
  55. unrestricted anonymous file transfer on the Internet.
  56.  
  57. If this FAQ is reproduced in offline media (e.g., CD-ROM, print form,
  58. etc.), a complimentary copy should be sent to Mark Kantrowitz, School
  59. of Computer Science, Carnegie Mellon University, 5000 Forbes Avenue,
  60. Pittsburgh, PA 15213-3891 USA.
  61.  
  62. This article is provided AS IS without any express or implied warranty.
  63.  
  64. *** Topics Covered:
  65.  
  66. There are currently seven parts to the Lisp FAQ:
  67.  
  68.    1. Introductory Matter and Bibliography of Introductions and References
  69.    2. General Questions
  70.    3. Common Programming Pitfalls
  71.    4. Lisp Implementations and Mailing Lists
  72.    5. Object-oriented Programming in Lisp
  73.    6. FTP Archives and Resources
  74.    7. Lisp Window Systems and GUIs
  75.  
  76. All parts are posted to comp.lang.lisp. Part 5 is cross-posted to the
  77. comp.lang.clos newsgroup.  
  78.  
  79. Topics Covered (Part 1):
  80.  
  81.   [1-0]   What is the purpose of this newsgroup?
  82.   [1-1]   What is the difference between Scheme and Common Lisp?
  83.   [1-2]   Lisp books, introductions, documentation, periodicals,
  84.           journals, and conference proceedings. 
  85.   [1-3]   How can I improve my Lisp programming style and coding efficiency?
  86.   [1-4]   Where can I learn about implementing Lisp interpreters and compilers?
  87.   [1-5]   What is the "minimal" set of primitives needed for a Lisp
  88.           interpreter? 
  89.   [1-6]   What does CLOS, PCL, X3J13, CAR, CDR, ... mean? 
  90.   [1-7]   Lisp Job Postings
  91.  
  92. Topics Covered (Part 2):
  93.  
  94.   [2-1]   Is there a GNU-Emacs interface to Lisp?
  95.   [2-2]   When should I use a hash table instead of an association list?
  96.   [2-3]   What is the equivalent of EXPLODE and IMPLODE in Common Lisp?
  97.   [2-4]   Is Lisp inherently slower than more conventional languages such as C?
  98.   [2-5]   Why does Common Lisp have "#'"?
  99.   [2-6]   How do I call non-Lisp functions from Lisp?
  100.   [2-7]   Can I call Lisp functions from other languages?
  101.   [2-8]   I want to call a function in a package that might not exist at
  102.           compile time. How do I do this?  
  103.   [2-9]   What is CDR-coding?
  104.   [2-10]  What is garbage collection?
  105.   [2-11]  How do I save an executable image of my loaded Lisp system?
  106.           How do I run a Unix command in my Lisp? How do I exit Lisp?
  107.   [2-12]  I'm porting some code from a Symbolics Lisp machine to some
  108.           other platform, and there are strange characters in the code.
  109.           What do they mean?  
  110.   [2-13]  History: Where did Lisp come from?
  111.   [2-14]  How do I find the argument list of a function?
  112.           How do I get the function name from a function object?
  113.   [2-15]  How can I have two Lisp processes communicate via unix sockets?
  114.   [2-16]  How can I create a stream that acts like UNIX's /dev/null
  115.           (i.e., gobbles any output and immediately signals EOF on
  116.           input operations)?
  117.   [2-17]  Read-time conditionalization of code (#+ #- and *features*)
  118.   [2-18]  What reader macro characters are used in major Lisp systems?
  119.   [2-19]  How do I determine if a file is a directory or not? 
  120.           How do I get the current directory name from within a Lisp 
  121.           program? Is there any way to create a directory?
  122.   [2-20]  What is a "Lisp Machine" (LISPM)?
  123.   [2-21]  How do I tell if a symbol names a function and not a macro?
  124.  
  125. Common Pitfalls (Part 3):
  126.  
  127.   [3-0]  Why does (READ-FROM-STRING "foobar" :START 3) return FOOBAR
  128.          instead of BAR?  
  129.   [3-1]  Why can't it deduce from (READ-FROM-STRING "foobar" :START 3)
  130.          that the intent is to specify the START keyword parameter
  131.          rather than the EOF-ERROR-P and EOF-VALUE optional parameters?   
  132.   [3-2]  Why can't I apply #'AND and #'OR?
  133.   [3-3]  I used a destructive function (e.g. DELETE, SORT), but it
  134.          didn't seem to work.  Why? 
  135.   [3-4]  After I NREVERSE a list, it's only one element long.  After I
  136.          SORT a list, it's missing things.  What happened? 
  137.   [3-5]  Why does (READ-LINE) return "" immediately instead of waiting
  138.          for me to type a line?  
  139.   [3-6]  I typed a form to the read-eval-print loop, but nothing happened. Why?
  140.   [3-7]  DEFMACRO doesn't seem to work.
  141.          When I compile my file, LISP warns me that my macros are undefined
  142.          functions, or complains "Attempt to call <function> which is 
  143.          defined as a macro.
  144.   [3-8]  Name conflict errors are driving me crazy! (EXPORT, packages)
  145.   [3-9]  Closures don't seem to work properly when referring to the
  146.          iteration variable in DOLIST, DOTIMES, DO and LOOP.
  147.   [3-10] What is the difference between FUNCALL and APPLY?
  148.   [3-11] Miscellaneous things to consider when debugging code.
  149.   [3-12] When is it right to use EVAL?
  150.   [3-13] Why does my program's behavior change each time I use it?
  151.   [3-14] When producing formatted output in Lisp, where should you put the
  152.          newlines (e.g., before or after the line, FRESH-LINE vs TERPRI,
  153.          ~& vs ~% in FORMAT)?
  154.   [3-15] I'm using DO to do some iteration, but it doesn't terminate. 
  155.   [3-16] My program works when interpreted but not when compiled!
  156.  
  157. Lisp Implementations and Mailing Lists (Part 4):
  158.  
  159.   [4-0]   Free Common Lisp implementations.
  160.   [4-1]   Commercial Common Lisp implementations.
  161.   [4-1a]  Lisp-to-C translators
  162.   [4-2]   Scheme Implementations
  163.   [4-4]   Free Implementations of Other Lisp Dialects
  164.   [4-5]   Commercial Implementations of Other Lisp Dialects
  165.   [4-6]   What is Dylan?
  166.   [4-7]   What is Pearl Common Lisp?
  167.   [4-9]   What Lisp-related discussion groups and mailing lists exist?
  168.   [4-10]  ANSI Common Lisp -- Where can I get a copy of the draft standard?
  169.  
  170. Object-oriented Programming in Lisp (Part 5):
  171.  
  172.   [5-0]   What is CLOS (PCL) and where can I get it?
  173.           How do you pronounce CLOS? What is the Meta-Object Protocol (MOP)?
  174.   [5-1]   What documentation is available about object-oriented
  175.           programming in Lisp?  
  176.   [5-2]   How do I write a function that can access defstruct slots by
  177.           name?  I would like to write something like 
  178.           (STRUCTURE-SLOT <object> '<slot-name>).   
  179.   [5-3]   How can I list all the CLOS instances in a class?
  180.   [5-4]   How can I store data and CLOS instances (with possibly circular
  181.           references) on disk so that they may be retrieved at some later
  182.           time? (Persistent Object Storage)
  183.   [5-5]   Given the name of a class, how can I get the names of its slots?
  184.   [5-6]   Free CLOS software.
  185.   [5-7]   Common CLOS Blunders
  186.  
  187. FTP Resources (Part 6):
  188.  
  189.   [6-0] General information about FTP Resources for Lisp
  190.   [6-1] Repositories of Lisp Software
  191.   [6-3] Publicly Redistributable Lisp Software
  192.   [6-6] Formatting code in LaTeX (WEB and other literate programming tools)
  193.   [6-7] Where can I get an implementation of Prolog in Lisp?
  194.   [6-8] World-Wide Web (WWW) Resources
  195.  
  196. Lisp Window Systems and GUIs (Part 7):
  197.   [7-1] How can I use the X Window System or other GUIs from Lisp?
  198.   [7-2] What Graphers/Browsers are available?
  199.  
  200. Search for \[#\] to get to question number # quickly.
  201.  
  202. *** Recent Changes:
  203.  
  204. ;;; 1.48:
  205. ;;; 13-JUL-94 mk    Updated Marlais entry in part 4.
  206. ;;; 14-JUL-94 mk    Updated DTP entry in part 6.
  207. ;;; 14-JUL-94 mk    Added entry on Lisp2Wish to part 7.
  208. ;;; 15-JUL-94 mk    Updated WCL entry (version 2.2 for solaris).
  209. ;;; 21-JUL-94 mk    Expanded ILU entry in part 6.
  210. ;;; 22-JUL-94 mk    Updated the Common Lisp Repository entry with information
  211. ;;;                 about the Prime Time Freeware for AI CD-ROM publication,
  212. ;;;                 keyword searching, etc., etc., etc.
  213. ;;; 11-AUG-94 mk    Added ftp site for source code to Graham's "On Lisp" book.
  214. ;;; 12-AUG-94 mk    Lisp-Jobs mailing list has moved.
  215. ;;; 12-AUG-94 mk    Added amiga-lisp mailing list to [4-9].
  216. ;;;
  217. ;;; 1.49:
  218. ;;; 23-AUG-94 mk    Moved the lisp-faq mailing list (for maintenance of the
  219. ;;;                 FAQ) from think.com to ai+lisp-faq@cs.cmu.edu.
  220. ;;;                 FAQ no longer available from ftp.think.com.
  221. ;;; 23-AUG-94 mk    Digital Press is now owned by Butterworth-Heinemann,
  222. ;;;                 and their new address is: 
  223. ;;;                    Digital Press, 80 Montvale Avenue, Stoneham, MA 02180
  224. ;;;                    Tel: 800-366-2665 (617-438-8464), Fax: 617-297-4851.
  225. ;;; 26-AUG-94 mk    Updated ILISP entry in [2-1].
  226. ;;; 26-AUG-94 mk    Added entry on JLISP to [4-4].
  227. ;;; 29-AUG-94 mk    CLtL2 now available by anonymous FTP, courtesy of
  228. ;;;                 Butterworth-Heinemann, the new owners of Digital Press.
  229. ;;; 30-AUG-94 mk    Numbers for Digital Press have changed. They are now      
  230. ;;;                 Tel: 800-366-2665 (USA) or 617-928-2500
  231. ;;;                 Fax: 800-446-6520 (USA) or 617-933-6333
  232. ;;;  8-SEP-94 mk    Corrected expansion for SC22/WG16 in [1-6] glossary.
  233. ;;;
  234. ;;; 1.50:
  235. ;;; 14-SEP-94 mk    Improved IDEAL entry in [6-3].
  236. ;;; 20-SEP-94 mk    Added "How do I exit Lisp?" to [2-11].
  237. ;;; 22-SEP-94 mk    Added Paul Graham's implementation of Prolog in Common Lisp
  238. ;;;                 to [6-7].
  239. ;;; 11-OCT-94 mk    Updated Venue entry in Part 4, and slight revisions in most
  240. ;;;                 other commercial Lisp implementations.
  241. ;;; 12-OCT-94 mk    Updated Harlequin Lispworks entry, and added new entry on
  242. ;;;                 Harlequin FreeLisp to part 4.
  243. ;;; 12-OCT-94 mk    Added ftp site for Kamin's original pascal implementation
  244. ;;;                 of his interpreters to [1-4].
  245. ;;;
  246. ;;; 1.51:
  247. ;;; 13-OCT-94 mk    Added   [2-21]  How do I tell if a symbol names a function
  248. ;;;                 and not a macro?
  249. ;;; 20-OCT-94 mk    Added [5-7] Common CLOS Blunders by Marty Hall.
  250. ;;;  3-NOV-94 mk    Added Christian Queinnec's Lisp book to [1-4].
  251. ;;;  4-NOV-94 mk    Updated CMU CL entry. 17f w/ Solaris, SGI MIPS, and DEC
  252. ;;;                 Alpha released.
  253. ;;; 10-NOV-94 mk    Digitool to produce PowerPC version of MCL.
  254. ;;; 11-NOV-94 mk    Updated ISO Lisp paragraph in [4-10].
  255. ;;; 11-NOV-94 mk    Updated LispWorks for Harlequin entry in part 4.
  256.  
  257. *** Introduction:
  258.  
  259. Certain questions and topics come up frequently in the various network
  260. discussion groups devoted to and related to Lisp.  This file/article is
  261. an attempt to gather these questions and their answers into a convenient
  262. reference for Lisp programmers.  It (or a reference to it) is posted
  263. periodically.  The hope is that this will cut down on the user time and
  264. network bandwidth used to post, read and respond to the same questions
  265. over and over, as well as providing education by answering questions
  266. some readers may not even have thought to ask.
  267.  
  268. This is not a Lisp tutorial, nor is it an exhaustive list of all Lisp
  269. intricacies.  Lisp is a very powerful and expressive language, but with
  270. that power comes many complexities.  This list attempts to address the
  271. ones that average Lisp programmers are likely to encounter.  If you are
  272. new to Lisp, see the answer to the question "How can I learn Lisp?".
  273.  
  274. The latest version of this FAQ is available via anonymous FTP from CMU:
  275.  
  276.    To obtain the files from CMU, connect by anonymous FTP to 
  277.       ftp.cs.cmu.edu:/user/ai/pubs/faqs/lisp/  [128.2.206.173]
  278.    using username "anonymous" and password "name@host" (substitute your
  279.    email address) or via AFS in the Andrew File System directory
  280.       /afs/cs.cmu.edu/project/ai-repository/ai/pubs/faqs/lisp/
  281.    and get the files lisp_1.faq, lisp_2.faq, lisp_3.faq, lisp_4.faq,
  282.    lisp_5.faq, lisp_6.faq and lisp_7.faq.
  283.  
  284. You can also obtain a copy of the FAQ by sending a message to
  285. ai+query@cs.cmu.edu with 
  286.    Send Lisp FAQ
  287. in the message body.
  288.  
  289. The FAQ postings are also archived in the periodic posting archive on
  290.    rtfm.mit.edu:/pub/usenet/news.answers/lisp-faq/ [18.181.0.24]
  291. If you do not have anonymous ftp access, you can access the archive by
  292. mail server as well.  Send an E-mail message to
  293. mail-server@rtfm.mit.edu with "help" and "index" in the body on
  294. separate lines for more information.
  295.  
  296. An automatically generated HTML version of the Lisp FAQ is accessible by
  297. WWW as part of the AI-related FAQs Mosaic page. The URL for this
  298. resource is
  299.    http://www.cs.cmu.edu:8001/Web/Groups/AI/html/faqs/top.html
  300. The direct URL for the Lisp FAQ is
  301.    http://www.cs.cmu.edu:8001/Web/Groups/AI/html/faqs/lang/lisp/top.html
  302.  
  303. Unless otherwise specified, the Lisp dialect referred to is Common Lisp,
  304. as defined by "Common Lisp: the Language" (aka "CLtL1") as well as
  305. corrections (but not enhancements) from "Common Lisp: the Language, 2nd
  306. Edition" (aka "CLtL2"), both by Guy L. Steele, Jr. and published by
  307. Digital Press. Note that CLtL2 is NOT an official specification for
  308. the language; ANSI Committee X3J13 is preparing such a specification.
  309. See question [4-10] for information on the status of the ANSI
  310. specification for Common Lisp. Enhancements such as CLOS, conditions,
  311. and the LOOP macro will be referred to separately.
  312.  
  313. If you need to cite the FAQ for some reason, use the following format:
  314.    Mark Kantrowitz and Barry Margolin, "Answers to Frequently Asked
  315.    Questions about Lisp", comp.lang.lisp, <month>, <year>,
  316.    ftp.cs.cmu.edu:/user/ai/pubs/faqs/lisp/lisp_?.faq, ai+lisp-faq@cs.cmu.edu.
  317.  
  318. ----------------------------------------------------------------
  319. Subject: [1-0] What is the purpose of this newsgroup?
  320.  
  321. The newsgroup comp.lang.lisp exists for general discussion of
  322. topics related to the programming language Lisp. For example, possible
  323. topics can include (but are not necessarily limited to):
  324.    announcements of Lisp books and products
  325.    discussion of programs and utilities written in Lisp
  326.    discussion of portability issues
  327.    questions about possible bugs in Lisp implementations
  328.    problems porting an implementation to some architecture
  329. Postings should be of general interest to the Lisp community. See also
  330. question [4-9]. Postings asking for solutions to homework problems are
  331. inappropriate. 
  332.  
  333. Every so often, somebody posts an inflammatory message, such as
  334.    My programming language is better than yours (Lisp vs. C/Prolog/Scheme). 
  335.    Loop (or Series) should/shouldn't be part of the language.
  336. These "religious" issues serve no real purpose other than to waste
  337. bandwidth. If you feel the urge to respond to such a post, please do
  338. so through a private e-mail message. 
  339.  
  340. Questions about object oriented programming in Lisp should be directed
  341. to the newsgroup comp.lang.clos. Similarly, questions about the
  342. programming language Scheme should be directed to the newsgroup
  343. comp.lang.scheme. Discussion of functional programming language issues
  344. should be directed to the newsgroup comp.lang.functional. Discussion
  345. of AI programs implemented in Lisp should sometimes be cross-posted to
  346. the newsgroup comp.ai.
  347.  
  348. ----------------------------------------------------------------
  349. Subject: [1-1] What is the difference between Scheme and Common Lisp?
  350.  
  351. Scheme is a dialect of Lisp that stresses conceptual elegance and
  352. simplicity. It is specified in R4RS and IEEE standard P1178. (See
  353. the Scheme FAQ for details on standards for Scheme.) Scheme is much
  354. smaller than Common Lisp; the specification is about 50 pages,
  355. compared to Common Lisp's 1300 page draft standard. (See question
  356. [4-10] for details on standards for Common Lisp.) Advocates of Scheme
  357. often find it amusing that the Scheme standard is shorter than the
  358. index to CLtL2. 
  359.  
  360. Scheme is often used in computer science curricula and programming
  361. language research, due to its ability to represent many programming
  362. abstractions with its simple primitives. Common Lisp is often used for
  363. real world programming because of its large library of utility
  364. functions, a standard object-oriented programming facility (CLOS), and
  365. a sophisticated condition handling system.
  366.  
  367. See the Scheme FAQ for information about object-oriented programming
  368. in Scheme. 
  369.  
  370. In Common Lisp, a simple program would look something like the
  371. following:
  372.  
  373.    (defun fact (n)
  374.      (if (< n 2)
  375.          1
  376.          (* n (fact (1- n)))))
  377.  
  378. In Scheme, the equivalent program would like like this:
  379.  
  380.    (define fact
  381.      (lambda (n)
  382.        (if (< n 2)
  383.            1
  384.          (* n (fact (- n 1))))))
  385.  
  386. Experienced Lisp programmers might write this program as follows in order
  387. to allow it to run in constant space:
  388.  
  389.    (defun fact (n)
  390.      (labels ((tail-recursive-fact (counter accumulator)
  391.                 (if (> counter n)
  392.                     accumulator
  393.                     (tail-recursive-fact (1+ counter)
  394.                                          (* counter accumulator)))))
  395.        (tail-recursive-fact 1 1)))
  396.  
  397. Whereas in Scheme the same computation could be written as follows:
  398.  
  399.    (define fact
  400.      (lambda (n)
  401.        (letrec ((tail-recursive-fact
  402.                  (lambda (counter accumulator)
  403.                    (if (> counter n)
  404.                        accumulator
  405.                      (tail-recursive-fact (+ counter 1)
  406.                                           (* counter accumulator))))))
  407.                (tail-recursive-fact 1 1))))
  408.  
  409. or perhaps (using IEEE named LETs):
  410.  
  411.    (define fact
  412.      (lambda (n)
  413.        (let loop ((counter n)
  414.                   (accumulator 1))
  415.             (if (< counter 2)
  416.                 accumulator
  417.               (loop (- counter 1)
  418.                     (* accumulator counter))))))
  419.  
  420. Some Schemes allow one to use the syntax (define (fact n) ...) instead
  421. of (define fact (lambda (n) ...)).
  422.  
  423. ----------------------------------------------------------------
  424. Subject: [1-2] Lisp books, introductions, documentation, periodicals,
  425.                journals, and conference proceedings. 
  426.  
  427. There are several good Lisp introductions and tutorials:
  428.  
  429.    1. David S. Touretzky
  430.       "Common Lisp: A Gentle Introduction to Symbolic Computation"
  431.       Benjamin/Cummings Publishers, Redwood City, CA, 1990. 592 pages.
  432.       ISBN 0-8053-0492-4. 
  433.            Perhaps the best tutorial introduction to the language. It has
  434.            clear and correct explanations, and covers some fairly advanced
  435.            topics. The book is an updated Common Lisp version of the 1984
  436.            edition published by Harper and Row Publishers. 
  437.  
  438.            Three free Lisp educational tools which were used in the book --
  439.            Evaltrace, DTRACE and SDRAW -- are available by anonymous ftp from
  440.               b.gp.cs.cmu.edu:/usr/dst/public/lisp/
  441.               b.gp.cs.cmu.edu:/usr/dst/public/evaltrace/
  442.        Evaltrace is a graphical notation for explaining how evaluation
  443.        works and is described in "Visualizing Evaluation in
  444.        Applicative Languages" by David S. Touretzky and Peter Lee,
  445.        CACM 45-59, October 1992. DTRACE is a "detailed trace" which
  446.        provides more information than the tracing tools provided with
  447.        most Common Lisp implementations. SDRAW is a read-eval-draw
  448.        loop that evaluates Lisp expressions and draws the result as a
  449.        cons cell diagram (for both X11 and ascii terminals). Also
  450.        available is PPMX, a tool for pretty printing macro expansions.
  451.  
  452.    2. Robert Wilensky
  453.       "Common LISPcraft"
  454.       W. W. Norton, 1986. 500 pages. ISBN 0-393-95544-3.
  455.  
  456.    3. Wade L. Hennessey 
  457.       "Common Lisp"
  458.       McGraw-Hill, 1989. 395 pages.
  459.            Fairly good, but jumps back and forth from the simple to the
  460.            complex rather quickly, with no clear progression in difficulty.
  461.  
  462.    4. Laurent Siklossy
  463.       "Let's Talk LISP"
  464.       Prentice-Hall, NJ, 1976. 237 pages.
  465.            Good introduction, but quite out of date.
  466.  
  467.    5. Stuart C. Shapiro
  468.       "Common Lisp: An Interactive Approach"
  469.       Computer Science Press/W.H. Freeman, New York, 1992.
  470.       ISBN 0-7167-8218-9
  471.          The errata for the book may be obtained by anonymous ftp from
  472.          ftp.cs.buffalo.edu:/users/shapiro/clerrata.ps
  473.  
  474. Other introductions to Lisp include:
  475.  
  476.    1. A. A. Berk.
  477.       "LISP, The Language of Artificial Intelligence"
  478.       Van Nostrand Reinhold, 1985. 160 pages.
  479.  
  480.    2. Paul Y. Gloess.
  481.       "An Alfred handy guide to Understanding LISP"
  482.       Alfred Publishers (Sherman Oaks, CA), 1982. 64 pages.
  483.  
  484.    3. Ward D. Maurer.
  485.       "The Programmer's Introduction to LISP"
  486.       American Elsevier, 1972. 112 pages.
  487.  
  488.    4. Hank Bromley and Richard Lamson.
  489.       "LISP Lore: A Guide to Programming the LISP Machine"
  490.       Kluwer Academic (Boston), 1987. 337 pages.
  491.  
  492.    5. Sharam Hekmatpour.
  493.       "Introduction to LISP and Symbol Manipulation"
  494.       Prentice Hall (New York), 1988. 303 pages.
  495.  
  496.    6. Deborah G. Tatar
  497.       "A programmer's guide to Common Lisp"
  498.       Digital Press, 1987. 327 pages. ISBN 0-932376-87-8.
  499.            Good introduction on Common Lisp for programmers familiar
  500.            with other programming languages, such as FORTRAN, PASCAL, or C.
  501.  
  502.    7. Timothy Koschmann
  503.       "The Common Lisp Companion"
  504.       John Wiley & Sons, 1990. ISBN 0-471-503-8-8.
  505.            Targeted for those with some programming experience who wish to 
  506.            learn draft-ANSI Common Lisp, including CLOS and the CL condition 
  507.            system. Examples progress incrementally from simple numerical 
  508.            calculation all the way to a logic-programming extension to CL.
  509.   
  510. More advanced introductions to Lisp and its use in Artificial
  511. Intelligence include:
  512.  
  513.    1. Peter Norvig.
  514.       "Paradigms of AI Programming: Case Studies in Common Lisp"
  515.       Morgan Kaufmann, 1992. 946 pages. ISBN 1-55860-191-0. $49.95.
  516.  
  517.         Provides an in-depth exposition of advanced AI programming techniques
  518.         and includes large-scale detailed examples. The book is the most
  519.         advanced AI/Common-Lisp programming text and reference currently
  520.         available, and hence is not for the complete novice.  It focuses on the
  521.         programming techniques necessary for building large AI systems,
  522.         including object-oriented programming, and has a strong performance
  523.         orientation.
  524.  
  525.         The text is marked by its use of "non-toy" examples to illustrate the
  526.         techniques. All of the examples are written in Common Lisp, and copies
  527.         of the source code are available by anonymous ftp from
  528.         unix.sri.com:/pub/norvig and on disk in Macintosh or DOS format from
  529.         the publisher. Some of the techniques described include rule-based
  530.         pattern matching (GPS, Eliza, a subset of Macsyma, the Emycin expert
  531.         system shell), constraint propagation and backtracking (Waltz
  532.         line-labelling), alpha-beta search (Othello), natural language
  533.         processing (top-down, bottom-up and chart parsing), logic-programming
  534.         (unification and Prolog), interpreters and compilers for Scheme, and
  535.         object-oriented programming (CLOS).
  536.  
  537.         The examples are also used to illustrate good programming style and
  538.         efficiency. There is a guide to trouble-shooting and debugging Lisp
  539.         programs, a style guide, and a discussion of portability problems.
  540.         Some of the efficiency techniques described include memoization,
  541.         data indexing, compilation, delaying computation, proper use of
  542.         declarations, avoiding garbage collection, and choosing and using the
  543.         correct data structure.
  544.  
  545.         The book also serves as an advanced introduction to Common Lisp, with
  546.         sections on the Loop macro, CLOS and sequences, and some coverage of 
  547.         error handling, series, and the package facility.
  548.  
  549.    2. Eugene Charniak, Christopher K. Riesbeck, Drew V. McDermott
  550.       and James R. Meehan.
  551.       "Artificial Intelligence Programming", 2nd edition.
  552.       Lawrence Erlbaum Associates (Hillsdale, NJ), 1987. 533 pages.
  553.            Provides many nice code fragments, all of which are written
  554.            in Common Lisp. The first half of the book covers topics
  555.            like macros, the reader, data structures, control structures,
  556.            and defstructs. The second half of the book describes
  557.            programming techniques specific to AI, such as
  558.            discrimination nets, production systems, deductive database
  559.            retrieval, logic programming, and truth maintenance.
  560.  
  561.    3. Patrick H. Winston and Berthold K. P. Horn.
  562.       "LISP", 3rd edition.
  563.       Addison-Wesley (Reading, MA), 1989. 611 pages. ISBN 0-201-08319-1
  564.            Covers the basic concepts of the language, but also gives a lot
  565.            of detail about programming AI topics such as rule-based expert
  566.            systems, forward chaining, interpreting transition trees, 
  567.            compiling transition trees, object oriented programming,
  568.            and finding patterns in images. Not a tutorial. Has many
  569.            good examples. Source code for the examples is available by
  570.            anonymous ftp from ftp.ai.mit.edu:/pub/lisp3/. (The code runs in
  571.            Lucid, Allegro, KCL, GCLisp, MCL, Symbolics Genera. Send mail
  572.            with subject line "help" to ai3@ai.mit.edu for more information.)
  573.  
  574.    4. John R. Anderson, Albert T. Corbett, and Brian J. Reiser.
  575.       "Essential LISP"
  576.       Addison-Wesley (Reading, MA), 1987. 352 pages.
  577.            Concentrates on how to use Lisp with iteration and recursion.
  578.  
  579.    5. Robert D. Cameron and Anthony H. Dixon
  580.       "Symbolic Computing with Lisp"
  581.       Prentice-Hall, 1992, 326 pages. ISBN 0-13-877846-9.
  582.            The book is intended primarily as a third-year computer science
  583.            text. In terms of programming techniques, it emphasizes recursion
  584.            and induction, data abstraction, grammar-based definition of Lisp
  585.            data structures and functional programming style. It uses
  586.            two Lisp languages: 
  587.                 (1) a purely functional subset of Lisp called Small Lisp and
  588.                 (2) Common Lisp.
  589.            An MS-DOS interpreter for Small Lisp (including source) is
  590.            provided with the book.  It considers applications of Lisp
  591.            to formal symbolic data domains: algebraic expressions,
  592.            logical formulas, grammars and programming languages. 
  593.  
  594.    6. Hasemer and Domingue.
  595.       "Common Lisp Programming for Artificial Intelligence"
  596.       Addison-Wesley, 1989.
  597.  
  598.    7. Steven Tanimoto
  599.       "The Elements of Artificial Intelligence: An Introduction Using Lisp"
  600.       Computer Science Press, Rockville, MD, 1987, 530 pages.
  601.  
  602.    8. Patrick R. Harrison
  603.       "Common Lisp and Artificial Intelligence"
  604.       Prentice Hall, Englewood Clifs, NJ, 1990. 244 pages. ISBN 0-13-155243.
  605.  
  606.    9. Paul Graham
  607.       "On Lisp: Advanced Techniques for Common Lisp"
  608.       Prentice Hall, Englewood Clifs, NJ, 1994. 400 pages, ISBN 0-13-030552-9.
  609.          Emphasizes a bottom-up style of writing programs, which he
  610.          claims is natural in Lisp and has advantages over the
  611.          traditional way of writing programs in C and Pascal.
  612.          Also has in-depth sections on writing macros with several
  613.          nice examples. Source code is available by anonymous ftp from
  614.             endor.harvard.edu:/pub/onlisp/ 
  615.          as a single 56kb file.
  616.  
  617. General Lisp reference books include:
  618.  
  619.    1. Guy L. Steele
  620.       "Common Lisp: The Language" [CLtL1]
  621.       Digital Press, 1984. 465 pages. ISBN 0-932376-41-X.
  622.  
  623.    2. Guy L. Steele
  624.       "Common Lisp: The Language, 2nd Edition" [CLtL2]
  625.       Digital Press, 1990. 1029 pages, ISBN 1-55558-041-6 paperbound ($39.95).
  626.  
  627.       [Butterworth-Heinemann, the owners of Digital Press, have made
  628.        the LaTeX sources to this book available by anonymous FTP from
  629.           cambridge.apple.com:/pub/CLTL/ 
  630.        A copy of the distribution is also available from
  631.           ftp.cs.cmu.edu:/user/ai/lang/lisp/doc/cltl/
  632.        The paperbound version of the book is, of course, available at
  633.        fine bookstores, or contact them directly at Digital Press, 
  634.        80 Montvale Avenue, Stoneham, MA 02180, call 800-366-2665
  635.        (617-928-2500), or fax 800-446-6520 (617-933-6333). A copy of
  636.        the Digital Press book catalog is available from the same FTP location.]
  637.  
  638.        A html version, produces using latex2html on the latex sources,
  639.        is accessible via the URL:
  640.            http://www.dcs.gla.ac.uk/~alison/clm/clm.html
  641.  
  642.    3. Franz Inc. 
  643.       "Common Lisp: The Reference"
  644.       Addison-Wesley, Reading, MA 1988. ISBN 0-201-11458-5
  645.            Entries on Lisp (CLtL1) functions in alphabetical order.
  646.  
  647. Lisp periodicals include:
  648.         
  649.    1. LISP Pointers.
  650.       Published by ACM SIGPLAN six times a year. Volume 1, Number 1
  651.       was April-May 1987. 
  652.       Subscriptions: ACM Members $12; ACM Student Members $7; Non-ACM
  653.       members $25. Mail checks payable to the ACM to ACM Inc., PO Box
  654.       12115, Church Street Station, New York, NY 10249.
  655.  
  656.    2. LISP and Symbolic Computation, Kluwer Academic Press. Volume 1
  657.       was published in 1989. (jlz@lucid.com is the editor).  ISSN 0892-4635.
  658.       Subscriptions: Institutions $169; Individuals $80. Add $8 for
  659.       air mail. Kluwer Academic Publishers, PO Box 322, 3300 AH Dordrecht, 
  660.       The Netherlands, or Kluwer Academic Publishers, PO Box 358, Accord
  661.       Station, Hingham, MA 02018-0358. 
  662.  
  663.       A full table of contents of all published issues, aims and scope, and
  664.       instructions for authors are available by anonymous ftp from
  665.          ftp.std.com:/Kluwer/journals/
  666.       as the files lisp.toc and lisp.inf.
  667.  
  668.    3. Proceedings of the biannual ACM Lisp and Functional Programming
  669.       Conference. (First one was in 1980.)
  670.  
  671.    4. Proceedings of the annual Lisp Users and Vendors Conference.
  672.  
  673. Implementation-specific questions:
  674.  
  675.    1. Lucid. See the wizards.doc file that comes with the Lucid
  676.       release. It describes functions, macros, variables and constants that
  677.       are not official parts of the product and are not supported.
  678.       Constructs described in this file include: the interrupt facility, the
  679.       source file recording facility, the resource facility, multitasking,
  680.       writing your own streams, lisp pipes, i/o buffers, the compiler,
  681.       floating-point functions, memory management, debugger information, the
  682.       window tool kit, extensions to the editor, the foreign function
  683.       interface, clos information, delivery toolkit information, and Lucid
  684.       lisp training classes. The wizards.doc file also covers i/o
  685.       constructs, functions for dealing with DEFSTRUCT, functions and
  686.       constants for dealing with procedure objects, functions and constants
  687.       for dealing with code objects, function for mapping objects,
  688.       additional keyword argument to DISKSAVE, function used in the
  689.       implementation of arrays, function for monitor-specific behavior for a
  690.       process, additional keyword argument to RUN-PROGRAM, and load-time
  691.       evaluation.
  692.  
  693. Many books on Scheme are worth reading even if you use Common Lisp,
  694. because many of the issues are similar. Scheme is a simpler language
  695. to learn, so it is often used in introductory computer science
  696. classes.  See the Scheme FAQ for a list of introductions and
  697. references for Scheme. The two key introductions are Abelson and
  698. Sussman's "Structure and Interpretation of Computer Programs" and 
  699. Friedman and Felleisen's "The Little LISPer". 
  700.  
  701. Special Topics:
  702.  
  703.    Garbage Collection:
  704.  
  705.       Wilson, Paul R., "Uniprocessor Garbage Collection Techniques"
  706.       Proceedings of the 1992 International Workshop on Memory Management.
  707.       Springer Lecture Notes #637. Surveys garbage collection techniques. 
  708.       Includes an excellent bibliography. Available by anonymous ftp from
  709.          cs.utexas.edu:/pub/garbage/gcsurvey.ps.
  710.       The BibTeX format of the bibliography is also available in this
  711.       directory, along with several other papers. Contact wilson@cs.utexas.edu
  712.       for more info.
  713.  
  714. ----------------------------------------------------------------
  715. Subject: [1-3] How can I improve my Lisp programming style and 
  716.                coding efficiency?
  717.  
  718. There are several books about Lisp programming style, including:
  719.    
  720.    1. Molly M. Miller and Eric Benson
  721.       "Lisp Style and Design"
  722.       Digital Press, 1990. 214 pages. ISBN 1-55558-044-0.
  723.            How to write large Lisp programs and improve Lisp programming 
  724.            style. Uses the development of Lucid CL as an example. 
  725.  
  726.    2. Robin Jones, Clive Maynard, and Ian Stewart.
  727.       "The Art of Lisp Programming"
  728.       Springer-Verlag, 1989. 169 pages, ISBN 0-387-19568-8 ($33).
  729.  
  730.    3. W. Richard Stark.
  731.       "LISP, Lore, and Logic: An Algebraic View of LISP
  732.        Programming, Foundations, and Applications"
  733.       Springer-Verlag, 1990. 278 pages. ISBN 0-387-97072-X paper ($42).
  734.            Self-modifying code, self-reproducing programs, etc.
  735.  
  736.    4. CMU CL User's Manual, Chapter 7, (talks about writing
  737.       efficient code). It is available by anonymous ftp from any CMU CS 
  738.       machine (e.g., ftp.cs.cmu.edu [128.2.206.173]) as the file
  739.         /afs/cs.cmu.edu/project/clisp/docs/cmu-user/cmu-user.ps 
  740.       [when getting this file by anonymous ftp, one must cd to 
  741.       the directory in one atomic operation, as some of the superior
  742.       directories on the path are protected from access by anonymous ftp.]
  743.  
  744.    5. See also Norvig's book, SICP (Abelson & Sussman), SAP
  745.       (Springer and Friedman).
  746.  
  747.    6. Hallvard Tretteberg's Lisp Style Guide is available by anonymous
  748.       ftp in ftp.think.com:/public/think/lisp/style-guide.text. There is
  749.       a fair bit of overlap between Hallvard's style guide and the notes
  750.       below and in part 3 of this FAQ.
  751.  
  752.    7. Rajeev Sangal
  753.       "Programming Paradigms in Lisp"
  754.       McGraw-Hill, 1991. ISBN 0-07-054666-5.
  755.  
  756.    8. Rodney A. Brooks.
  757.       "Programming in Common Lisp"
  758.       John Wiley & Sons, New York, 1985. 303 pages. ISBN 0-471-81888-7.
  759.       Chapter 5 discusses Lisp programming style.
  760.  
  761. Here are some general suggestions/notes about improving Lisp
  762. programming style, readability, correctness and efficiency:
  763.  
  764.    General Programming Style Rules:
  765.  
  766.       - Write short functions, where each function provides a single,
  767.         well-defined operation. Small functions are easier to
  768.         read, write, test, debug, and understand.
  769.  
  770.       - Use descriptive variable and function names. If it isn't clear
  771.         from the name of a function or variable what its purpose is,
  772.         document it with a documentation string and a comment. In fact,
  773.         even if the purpose is evident from the name, it is still worth
  774.         documenting your code.
  775.  
  776.       - Don't write Pascal (or C) code in Lisp. Use the appropriate
  777.         predefined functions -- look in the index to CLtL2, or use the
  778.         APROPOS and DESCRIBE functions. Don't put a close parenthesis
  779.         on a line by itself -- this can really aggravate programmers
  780.         who grew up on Lisp. Lisp-oriented text editors include tools
  781.         for ensuring balanced parentheses and for moving across 
  782.         pairs of balanced parentheses. You don't need to stick
  783.         comments on close parentheses to mark which expression they close.
  784.  
  785.       - Use proper indentation -- you should be able to understand
  786.         the structure of your definitions without noticing the parentheses. 
  787.         In general, the way one indents a form is controlled by the
  788.         first symbol of the form. In DEFUNs, for example, one puts the
  789.         symbol DEFUN, the function name, and the argument list all on
  790.         the same line. If the argument list is too long, one can break
  791.         it at one of the lambda keywords. Following the argument list,
  792.         one inserts a carriage return and lists the expressions in the
  793.         body of the definition, with each form starting on its own
  794.         line indented three spaces relative to the open parenthesis of
  795.         the parent (in this case the DEFUN). This general style -- of
  796.         putting all the significant elements of a form on a single
  797.         line, followed by a carriage return and the indented body --
  798.         holds for many Lisp constructs. There are, of course, variations,
  799.         such as keeping the first clause on the same line as the COND
  800.         or CASE symbol, and the rules are relaxed in different ways to
  801.         keep line lengths to a manageable size. If you find yourself having
  802.         trouble fitting everything in even with line breaking and
  803.         relaxing the rules, either your function names are too long or your
  804.         code isn't very modular. You should perceive this as a signal that
  805.         you need to break up your big definitions into smaller chunks, each
  806.         with a clearly defined purpose, and possibly replace long function
  807.         names with concise but apt shorter ones.
  808.  
  809.       - Use whitespace appropriately. Use whitespace to separate
  810.         semantically distinct code segments, but don't use too much
  811.         whitespace. For example,
  812.            GOOD: 
  813.               (defun foo (x y)
  814.                 (let ((z (+ x y 10)))
  815.                   (* z z)))
  816.  
  817.            BAD: 
  818.               (defun foo(x y)(let((z(+ x y 10)))(* z z)))
  819.  
  820.               (defun foo ( x  y )
  821.                 (let ( ( z (+ x y 10) ) )
  822.                   ( * z z )
  823.                   )
  824.                 )    
  825.          Although the Lisp reader and compiler don't care which you
  826.          use, most experienced Lisp programs find the first example much easier
  827.          to read than the last two.
  828.  
  829.        - Don't use line lengths greater than 80 characters. People who
  830.          write code using Zmacs on Symbolics Lisp Machines are notoriously
  831.          guilty of violating this rule, because the CPT6 font allows
  832.          one to squeeze a tremendous amount of code on the display,
  833.          especially if one spreads the code out horizontally. This
  834.          makes it more difficult to read when printed out or read on
  835.          an 80x24 xterm window. In fact, use a line length of 72 characters
  836.          because it leaves a strip of white space at the edge of the window.
  837.  
  838.    The following functions often abused or misunderstood by novices. 
  839.    Think twice before using any of these functions.
  840.  
  841.       - EVAL. Novices almost always misuse EVAL. When experts use
  842.         EVAL, they often would be better off using APPLY, FUNCALL, or
  843.         SYMBOL-VALUE. Use of EVAL when defining a macro should set off
  844.         a warning bell -- macro definitions are already evaluated
  845.         during expansion. See also the answer to question 3-12.
  846.         The general rule of thumb about EVAL is: if you think you need
  847.         to use EVAL, you're probably wrong.
  848.  
  849.       - PROGV. PROGV binds dynamic variables and is often misused in
  850.         conjunction with EVAL, which uses the dynamic environment. 
  851.         In general, avoid unnecessary use of special variables.
  852.         PROGV is mainly for writing interpreters for languages embedded
  853.         in Lisp. If you want to bind a list of values to a list of
  854.         lexical variables, use
  855.             (MULTIPLE-VALUE-BIND (..) (VALUES-LIST ..) ..)
  856.         or
  857.             (MULTIPLE-VALUE-SETQ (..) (VALUES-LIST ..))
  858.         instead. Most decent compilers can optimize this expression. 
  859.         However, use of this idiom is not to be encouraged unless absolutely
  860.         necessary.
  861.  
  862.       - CATCH and THROW. Often a named BLOCK and RETURN-FROM are
  863.         more appropriate. Use UNWIND-PROTECT when necessary.
  864.  
  865.       - Destructive operations, such as NCONC, SORT, DELETE,
  866.         RPLACA, and RPLACD, should be used carefully and sparingly.
  867.         In general, trust the garbage collector: allocate new
  868.         data structures when you need them.
  869.  
  870.    To improve the readability of your code,
  871.  
  872.       - Don't use any C{A,D}R functions with more than two
  873.         letters between the C and the R. When nested, they become
  874.         hard to read. If you have complex data structures, you
  875.         are often better off describing them with a DEFSTRUCT,
  876.         even if the type is LIST. The data abstraction afforded by
  877.         DEFSTRUCT makes the code much more readable and its purpose
  878.         clearer. If you must use C{A,D}R, try to use
  879.         DESTRUCTURING-BIND instead, or at least SECOND, THIRD, 
  880.         NTH, NTHCDR, etc.
  881.  
  882.       - Use COND instead of IF and PROGN. In general, don't use PROGN if
  883.         there is a way to write the code within an implicit
  884.         PROGN. For example, 
  885.            (IF (FOO X)
  886.                (PROGN (PRINT "hi there") 23)
  887.                34)
  888.         should be written using COND instead.
  889.  
  890.       - Never use a 2-argument IF or a 3-argument IF with a second
  891.         argument of NIL unless you want to emphasize the return value;
  892.         use WHEN and UNLESS instead. You will want to emphasize the
  893.         return value when the IF clause is embedded within a SETQ,
  894.         such as (SETQ X (IF (EQ Y Z) 2 NIL)). If the second argument 
  895.         to IF is the same as the first, use OR instead: (OR P Q) rather
  896.         than (IF P P Q). Use UNLESS instead of (WHEN (NOT ..) ..)
  897.         but not instead of (WHEN (NULL ..) ..).
  898.  
  899.       - Use COND instead of nested IF statements. Be sure to check for
  900.         unreachable cases, and eliminate those cond-clauses.
  901.  
  902.       - Use backquote, rather than explicit calls to LIST, CONS, and
  903.         APPEND, whenever writing a form which produces a Lisp form, but
  904.         not as a general substitute for LIST, CONS and APPEND. LIST, 
  905.         CONS and APPEND usually allocate new storage, but lists produced
  906.         by backquote may involve destructive modification (e.g., ,.).
  907.  
  908.       - Make the names of special (global) variables begin and end
  909.         with an asterisk (*): (DEFVAR *GLOBAL-VARIABLE*)   
  910.         Some programmers will mark the beginning and end of an internal
  911.         global variable with a percent (%) or a period (.).
  912.         Make the names of constants begin and end with a plus (+):
  913.         (DEFCONSTANT +E+ 2.7182818)
  914.         This helps distinguish them from lexical variables. Some people
  915.         prefer to use macros to define constants, since this avoids
  916.         the problem of accidentally trying to bind a symbol declared
  917.         with defconstant.
  918.  
  919.       - If your program is built upon an underlying substrate which is
  920.         implementation-dependent, consider naming those functions and
  921.         macros in a way that visually identifies them, either by placing
  922.         them in their own package, or prepending a character like a %, ., 
  923.         or ! to the function name. Note that many programmers use the
  924.         $ as a macro character for slot access, so it should be avoided
  925.         unless you're using it for that purpose.
  926.  
  927.       - Don't use property lists. Instead, use an explicit hash table.
  928.         This helps avoid problems caused by the symbol being in the wrong
  929.         package, accidental reuse of property keys from other
  930.         programs, and allows you to customize the structure of the table. 
  931.  
  932.       - Use the most specific construct that does the job. This lets
  933.         readers of the code see what you intended when writing the code.
  934.         For example, don't use SETF if SETQ will do (e.g., for lexical
  935.         variables). Using SETQ will tell readers of your code that you
  936.         aren't doing anything fancy. Likewise, don't use EQUAL where EQ
  937.         will do. Use the most specific predicate to test your conditions. 
  938.         
  939.       - If you intend for a function to be a predicate, have it return T
  940.         for true, not just non-NIL. If there is nothing worth returning
  941.         from a function, returning T is conventional. But if a function
  942.         is intended to be more than just a predicate, it is better to 
  943.         return a useful value. (For example, this is one of the differences
  944.         between MEMBER and FIND.)
  945.  
  946.       - When NIL is used as an empty list, use () in your code. When NIL
  947.         is used as a boolean, use NIL. Similarly, use NULL to test for an
  948.         empty list, NOT to test a logical value. Use ENDP to test for the
  949.         end of a list, not NULL.
  950.  
  951.       - Don't use the &AUX lambda-list keyword. It is always clearer to
  952.         define local variables using LET or LET*.
  953.  
  954.       - When using RETURN and RETURN-FROM to exit from a block, don't
  955.         use (VALUES ..) when returning only one value, except if you
  956.         are using it to suppress extra multiple values from the first
  957.         argument. 
  958.  
  959.       - If you want a function to return no values (i.e., equivalent to
  960.         VOID in C), use (VALUES) to return zero values. This signals
  961.         to the reader that the function is used mainly for side-effects.
  962.  
  963.       - (VALUES (VALUES 1 2 3)) returns only the first value, 1.
  964.         You can use (VALUES (some-multiple-value-function ..)) to suppress
  965.         the extra multiple values from the function. Use MULTIPLE-VALUE-PROG1
  966.         instead of PROG1 when the multiple values are significant.
  967.  
  968.       - When using MULTIPLE-VALUE-BIND and DESTRUCTURING-BIND, don't rely
  969.         on the fact that NIL is used when values are missing. This is
  970.         an error in some implementations of DESTRUCTURING-BIND. Instead,
  971.         make sure that your function always returns the proper number of
  972.         values.
  973.  
  974.       - Type the name of external symbols, functions, and variables
  975.         from the COMMON-LISP package in uppercase. This will allow your
  976.         code to work properly in a case-sensitive version of Common Lisp,
  977.         since the print-names of symbols in the COMMON-LISP package
  978.         are uppercase internally. (However, not everybody feels that
  979.         being nice to case-sensitive Lisps is a requirement, so this
  980.         isn't an absolute style rule, just a suggestion.)
  981.  
  982.     Lisp Idioms:
  983.  
  984.       - MAPCAN is used with a function to return a variable number of
  985.         items to be included in an output list. When the function returns zero
  986.         or one items, the function serves as a filter. For example,
  987.            (mapcan #'(lambda (x) (when (and (numberp x) (evenp x)) (list x)))
  988.                    '(1 2 3 4 x 5 y 6 z 7))
  989.  
  990.     Documentation:
  991.  
  992.       - Comment your code. Use three semicolons in the left margin before
  993.         the definition for major explanations. Use two semicolons that
  994.         float with the code to explain the routine that follows. Two
  995.         semicolons may also be used to explain the following line when the
  996.         comment is too long for the single semicolon treatment. Use
  997.         a single semicolon to the right of the code to explain a particular
  998.         line with a short comment. The number of semicolons used roughly
  999.         corresponds with the length of the comment. Put at least one blank
  1000.         line before and after top-level expressions.
  1001.  
  1002.       - Include documentation strings in your code. This lets users
  1003.         get help while running your program without having to resort to
  1004.         the source code or printed documentation. 
  1005.  
  1006.    Issues related to macros:
  1007.  
  1008.       - Never use a macro instead of a function for efficiency reasons.
  1009.         Declaim the function as inline -- for example, 
  1010.           (DECLAIM (INLINE ..))
  1011.         This is *not* a magic bullet -- be forewarned that inline
  1012.         expansions can often increase the code size dramatically. INLINE
  1013.         should be used only for short functions where the tradeoff is
  1014.         likely to be worthwhile: inner loops, types that the compiler
  1015.         might do something smart with, and so on.
  1016.  
  1017.       - When defining a macro that provides an implicit PROGN, use the
  1018.         &BODY lambda-list keyword instead of &REST.
  1019.  
  1020.       - Use gensyms for bindings within a macro, unless the macro lets
  1021.         the user explicitly specify the variable. For example:
  1022.             (defmacro foo ((iter-var list) body-form &body body)
  1023.               (let ((result (gensym "RESULT")))
  1024.                 `(let ((,result nil))
  1025.                    (dolist (,iter-var ,list ,result)
  1026.                      (setq ,result ,body-form)
  1027.                      (when ,result
  1028.                         ,@body)))))        
  1029.         This avoids errors caused by collisions during macro expansion
  1030.         between variable names used in the macro definition and in the
  1031.         supplied body.
  1032.  
  1033.       - Use a DO- prefix in the name of a macro that does some kind of
  1034.         iteration, WITH- when the macro establishes bindings, and
  1035.         DEFINE- or DEF- when the macro creates some definitions. Don't
  1036.         use the prefix MAP- in macro names, only in function names.
  1037.  
  1038.       - Don't create a new iteration macro when an existing function
  1039.         or macro will do.
  1040.  
  1041.       - Don't define a macro where a function definition will work just
  1042.         as well -- remember, you can FUNCALL or MAPCAR a function but 
  1043.         not a macro.
  1044.  
  1045.       - The LOOP and SERIES macros generate efficient code. If you're
  1046.         writing a new iteration macro, consider learning to use one
  1047.         of them instead.
  1048.   
  1049.    File Modularization:
  1050.  
  1051.       - If your program involves macros that are used in more than one
  1052.         file, it is generally a good idea to put such macros in a separate
  1053.         file that gets loaded before the other files. The same things applies
  1054.         to primitive functions. If a macro is complicated, the code that
  1055.         defines the macro should be put into a file by itself. In general, if
  1056.         a set of definitions form a cohesive and "independent" whole, they
  1057.         should be put in a file by themselves, and maybe even in their own
  1058.         package. It isn't unusual for a large Lisp program to have files named
  1059.         "site-dependent-code", "primitives.lisp", and "macros.lisp". If a file
  1060.         contains primarily macros, put "-macros" in the name of the file.
  1061.  
  1062.    Stylistic preferences:
  1063.  
  1064.       - Use (SETF (CAR ..) ..) and (SETF (CDR ..) ..) in preference to
  1065.         RPLACA and RPLACD. Likewise (SETF (GET ..) ..) instead of PUT.
  1066.  
  1067.       - Use INCF, DECF, PUSH and POP instead instead of the corresponding
  1068.         SETF forms.
  1069.  
  1070.       - Many programmers religiously avoid using CATCH, THROW, BLOCK,
  1071.         PROG, GO and TAGBODY.  Tags and go-forms should only be necessary
  1072.         to create extremely unusual and complicated iteration constructs. In
  1073.         almost every circumstance, a ready-made iteration construct or
  1074.         recursive implementation is more appropriate.
  1075.  
  1076.       - Don't use LET* where LET will do. Don't use LABELS where FLET
  1077.         will do. Don't use DO* where DO will do.
  1078.  
  1079.       - Don't use DO where DOTIMES or DOLIST will do.
  1080.  
  1081.       - If you like using MAPCAR instead of DO/DOLIST, use MAPC when
  1082.         no result is needed -- it's more efficient, since it doesn't
  1083.         cons up a list. If a single cumulative value is required, use
  1084.         REDUCE. If you are seeking a particular element, use FIND,
  1085.         POSITION, or MEMBER.
  1086.  
  1087.       - If using REMOVE and DELETE to filter a sequence, don't use the
  1088.         :test-not keyword or the REMOVE-IF-NOT or DELETE-IF-NOT functions.
  1089.         Use COMPLEMENT to complement the predicate and the REMOVE-IF
  1090.         or DELETE-IF functions instead.
  1091.  
  1092.       - Use complex numbers to represent points in a plane.
  1093.  
  1094.       - Don't use lists where vectors are more appropriate. Accessing the
  1095.         nth element of a vector is faster than finding the nth element
  1096.         of a list, since the latter requires pointer chasing while the
  1097.         former requires simple addition. Vectors also take up less space
  1098.         than lists. Use adjustable vectors with fill-pointers to
  1099.         implement a stack, instead of a list -- using a list continually
  1100.         conses and then throws away the conses.
  1101.  
  1102.       - When adding an entry to an association list, use ACONS, not
  1103.         two calls to CONS. This makes it clear that you're using an alist.
  1104.  
  1105.       - If your association list has more than about 10 entries in it,
  1106.         consider using a hash table. Hash tables are often more efficient.
  1107.         (See also [2-2].)
  1108.  
  1109.       - When you don't need the full power of CLOS, consider using
  1110.         structures instead. They are often faster, take up less space, and
  1111.         easier to use.
  1112.  
  1113.       - Use PRINT-UNREADABLE-OBJECT when writing a print-function.
  1114.  
  1115.       - Use WITH-OPEN-FILE instead of OPEN and CLOSE.
  1116.  
  1117.       - When a HANDLER-CASE clause is executed, the stack has already
  1118.         unwound, so dynamic bindings that existed when the error
  1119.         occured may no longer exist when the handler is run. Use
  1120.         HANDLER-BIND if you need this. 
  1121.  
  1122.       - When using CASE and TYPECASE forms, if you intend for the form
  1123.         to return NIL when all cases fail, include an explicit OTHERWISE
  1124.         clause. If it would be an error to return NIL when all cases
  1125.         fail, use ECASE, CCASE, ETYPECASE or CTYPECASE instead.
  1126.  
  1127.       - Use local variables in preference to global variables whenever
  1128.         possible. Do not use global variables in lieu of parameter passing.
  1129.         Global variables can be used in the following circumstances:
  1130.           *  When one function needs to affect the operation of
  1131.              another, but the second function isn't called by the first.
  1132.              (For example, *load-pathname* and *break-on-warnings*.)
  1133.           *  When a called function needs to affect the current or future
  1134.              operation of the caller, but it doesn't make sense to accomplish
  1135.              this by returning multiple values.
  1136.           *  To provide hooks into the mechanisms of the program.
  1137.              (For example, *evalhook*, *, /, and +.)
  1138.           *  Parameters which, when their value is changed, represent a
  1139.              major change to the program.
  1140.              (For example, *print-level* and *print-readably*.)
  1141.           *  For state that persists between invocations of the program.
  1142.              Also, for state which is used by more than one major program.
  1143.              (For example, *package*, *readtable*, *gensym-counter*.)
  1144.           *  To provide convenient information to the user.
  1145.              (For example, *version* and *features*.)
  1146.           *  To provide customizable defaults. 
  1147.              (For example, *default-pathname-defaults*.)
  1148.           *  When a value affects major portions of a program, and passing
  1149.              this value around would be extremely awkward. (The example
  1150.              here is output and input streams for a program. Even when
  1151.              the program passes the stream around as an argument, if you
  1152.              want to redirect all output from the program to a different
  1153.              stream, it is much easier to just rebind the global variable.)
  1154.  
  1155.       - Beginning students, especially ones accustomed to programming
  1156.         in C, Pascal, or Fortran, tend to use global variables to hold or pass
  1157.         information in their programs. This style is considered ugly by
  1158.         experienced Lisp programmers. Although assignment statements can't
  1159.         always be avoided in production code, good programmers take advantage
  1160.         of Lisp's functional programming style before resorting to SETF and
  1161.         SETQ. For example, they will nest function calls instead of using a
  1162.         temporary variable and use the stack to pass multiple values. When
  1163.         first learning to program in Lisp, try to avoid SETF/SETQ and their
  1164.         cousins as much as possible. And if a temporary variable is necessary,
  1165.         bind it to its first value in a LET statement, instead of letting it
  1166.         become a global variable by default. (If you see lots of compiler
  1167.         warnings about declaring variables to be special, you're probably
  1168.         making this mistake. If you intend a variable to be global, it should
  1169.         be defined with a DEFVAR or DEFPARAMETER statement, not left to the
  1170.         compiler to fix.)
  1171.  
  1172.    Correctness and efficiency issues:
  1173.  
  1174.       - In CLtL2, IN-PACKAGE does not evaluate its argument. Use defpackage
  1175.         to define a package and declare the external (exported)
  1176.         symbols from the package. 
  1177.  
  1178.       - The ARRAY-TOTAL-SIZE-LIMIT may be as small as 1024, and the
  1179.         CALL-ARGUMENTS-LIMIT may be as small as 50. 
  1180.  
  1181.       - Novices often mistakenly quote the conditions of a CASE form.
  1182.         For example, (case x ('a 3) ..) is incorrect. It would return
  1183.         3 if x were the symbol QUOTE. Use (case x (a 3) ..) instead.
  1184.  
  1185.       - Avoid using APPLY to flatten lists. Although 
  1186.            (apply #'append list-of-lists)
  1187.         may look like a call with only two arguments, it becomes a 
  1188.         function call to APPEND, with the LIST-OF-LISTS spread into actual
  1189.         arguments. As a result it will have as many arguments as there are
  1190.         elements in LIST-OF-LISTS, and hence may run into problems with the
  1191.         CALL-ARGUMENTS-LIMIT. Use REDUCE or MAPCAN instead:  
  1192.            (reduce #'append list-of-lists :from-end t)
  1193.            (mapcan #'copy-list list-of-lists)
  1194.         The second will often be more efficient (see note below about choosing
  1195.         the right algorithm). Beware of calls like (apply f (mapcar ..)).
  1196.  
  1197.       - NTH must cdr down the list to reach the elements you are
  1198.         interested in. If you don't need the structural flexibility of
  1199.         lists, try using vectors and the ELT function instead.
  1200.  
  1201.       - CASE statements can be vectorized if the keys are consecutive
  1202.         numbers. Such CASE statements can still have OTHERWISE clauses.
  1203.         To take advantage of this without losing readability, use #. with 
  1204.         symbolic constants:
  1205.  
  1206.             (eval-when (compile load eval)
  1207.                (defconstant RED 1)
  1208.                (defconstant GREEN 2)
  1209.                (defconstant BLUE 3))
  1210.  
  1211.             (case color
  1212.               (#.RED   ...)
  1213.               (#.GREEN ...)
  1214.               (#.BLUE  ...)
  1215.               ...)
  1216.  
  1217.       - Don't use quoted constants where you might later destructively
  1218.         modify them. For example, instead of writing '(c d) in
  1219.            (defun foo ()
  1220.              (let ((var '(c d)))
  1221.                ..))
  1222.         write (list 'c 'd) instead. Using a quote here can lead to
  1223.         unexpected results later. If you later destructively modify the 
  1224.         value of var, this is self-modifying code! Some Lisp compilers
  1225.         will complain about this, since they like to make constants
  1226.         read-only. Modifying constants has undefined results in ANSI CL.
  1227.         See also the answer to question [3-13].
  1228.  
  1229.         Similarly, beware of shared list structure arising from the use
  1230.         of backquote. Any sublist in a backquoted expression that doesn't
  1231.         contain any commas can share with the original source structure.
  1232.  
  1233.       - Don't proclaim unsafe optimizations, such as
  1234.            (proclaim '(optimize (safety 0) (speed 3) (space 1))) 
  1235.         since this yields a global effect. Instead, add the
  1236.         optimizations as local declarations to small pieces of
  1237.         well-tested, performance-critical code:
  1238.            (defun well-tested-function ()
  1239.               (declare (optimize (safety 0) (speed 3) (space 1)))
  1240.              ..)
  1241.         Such optimizations can remove run-time type-checking; type-checking
  1242.         is necessary unless you've very carefully checked your code
  1243.         and added all the appropriate type declarations.
  1244.  
  1245.       - Some programmers feel that you shouldn't add declarations to
  1246.         code until it is fully debugged, because incorrect
  1247.         declarations can be an annoying source of errors. They recommend
  1248.         using CHECK-TYPE liberally instead while you are developing the code.
  1249.         On the other hand, if you add declarations to tell the
  1250.         compiler what you think your code is doing, the compiler can
  1251.         then tell you when your assumptions are incorrect.
  1252.         Declarations also make it easier for another programmer to read
  1253.         your code. 
  1254.  
  1255.       - Declaring the type of variables to be FIXNUM does not
  1256.         necessarily mean that the results of arithmetic involving the 
  1257.         fixnums will be a fixnum; it could be a BIGNUM. For example,
  1258.            (declare (type fixnum x y))
  1259.            (setq z (+ (* x x) (* y y)))
  1260.         could result in z being a BIGNUM. If you know the limits of your
  1261.         numbers, use a declaration like
  1262.            (declare (type (integer 0 100) x y))
  1263.         instead, since most compilers can then do the appropriate type
  1264.         inference, leading to much faster code.
  1265.  
  1266.       - Don't change the compiler optimization with an OPTIMIZE
  1267.         proclamation or declaration until the code is fully debugged
  1268.         and profiled.  When first writing code you should say 
  1269.         (declare (optimize (safety 3))) regardless of the speed setting.
  1270.  
  1271.       - Depending on the optimization level of the compiler, type
  1272.         declarations are interpreted either as (1) a guarantee from
  1273.         you that the variable is always bound to values of that type,
  1274.         or (2) a desire that the compiler check that the variable is
  1275.         always bound to values of that type. Use CHECK-TYPE if (2) is
  1276.         your intention.
  1277.  
  1278.       - If you get warnings about unused variables, add IGNORE
  1279.         declarations if appropriate or fix the problem. Letting such
  1280.         warnings stand is a sloppy coding practice.
  1281.  
  1282.    To produce efficient code,
  1283.  
  1284.       - choose the right algorithm. For example, consider seven possible
  1285.         implementations of COPY-LIST:
  1286.  
  1287.            (defun copy-list (list)
  1288.              (let ((result nil))
  1289.                (dolist (item list result)
  1290.                  (setf result (append result (list item))))))
  1291.  
  1292.            (defun copy-list (list)
  1293.              (let ((result nil))
  1294.                (dolist (item list (nreverse result))
  1295.                  (push item result))))
  1296.  
  1297.            (defun copy-list (list)
  1298.              (mapcar #'identity list))
  1299.  
  1300.            (defun copy-list (list)
  1301.              (let ((result (make-list (length list))))
  1302.                (do ((original list (cdr original))
  1303.                     (new result (cdr new)))
  1304.                    ((null original) result)
  1305.                  (setf (car new) (car original)))))
  1306.  
  1307.            (defun copy-list (list)
  1308.              (when list
  1309.                (let* ((result (list (car list)))
  1310.                       (tail-ptr result))
  1311.                  (dolist (item (cdr list) result)
  1312.                    (setf (cdr tail-ptr) (list item))
  1313.                    (setf tail-ptr (cdr tail-ptr))))))
  1314.         
  1315.             (defun copy-list (list)
  1316.               (loop for item in list collect item))
  1317.  
  1318.             (defun copy-list (list)
  1319.               (if (consp list) 
  1320.                   (cons (car list)
  1321.                         (copy-list (cdr list)))
  1322.                   list))
  1323.  
  1324.         The first uses APPEND to tack the elements onto the end of the list.
  1325.         Since APPEND must traverse the entire partial list at each step, this
  1326.         yields a quadratic running time for the algorithm.  The second
  1327.         implementation improves on this by iterating down the list twice; once
  1328.         to build up the list in reverse order, and the second time to reverse
  1329.         it. The efficiency of the third depends on the Lisp implementation,
  1330.         but it is usually similar to the second, as is the fourth.  The fifth
  1331.         algorithm, however, iterates down the list only once. It avoids the
  1332.         extra work by keeping a pointer (reference) to the last cons of the 
  1333.         list and RPLACDing onto the end of that. Use of the fifth algorithm 
  1334.         may yield a speedup. Note that this contradicts the earlier dictum to
  1335.         avoid destructive functions. To make more efficient code one might
  1336.         selectively introduce destructive operations in critical sections of
  1337.         code. Nevertheless, the fifth implementation may be less efficient in
  1338.         Lisps with cdr-coding, since it is more expensive to RPLACD cdr-coded
  1339.         lists. Depending on the implementation of nreverse, however,
  1340.         the fifth and second implementations may be doing the same
  1341.         amount of work. The sixth example uses the Loop macro, which usually
  1342.         expands into code similar to the third. The seventh example copies
  1343.         dotted lists, and runs in linear time, but isn't tail-recursive. 
  1344.  
  1345.       - use type declarations liberally in time-critical code, but
  1346.         only if you are a seasoned Lisp programmer. Appropriate type
  1347.         declarations help the compiler generate more specific and
  1348.         optimized code. It also lets the reader know what assumptions
  1349.         were made. For example, if you only use fixnum arithmetic,
  1350.         adding declarations can lead to a significant speedup. If you
  1351.         are a novice Lisp programmer, you should use type declarations
  1352.         sparingly, as there may be no checking to see if the
  1353.         declarations are correct, and optimized code can be harder to
  1354.         debug. Wrong declarations can lead to errors in otherwise
  1355.         correct code, and can limit the reuse of code in other
  1356.         contexts. Depending on the Lisp compiler, it may also 
  1357.         be necessary to declare the type of results using THE, since
  1358.         some compilers don't deduce the result type from the inputs.
  1359.  
  1360.       - check the code produced by the compiler by using the
  1361.         disassemble function
  1362.  
  1363. ----------------------------------------------------------------
  1364. Subject: [1-4] Where can I learn about implementing Lisp interpreters 
  1365.                and compilers?
  1366.  
  1367. Books about Lisp implementation include:
  1368.  
  1369.    1. John Allen
  1370.       "Anatomy of Lisp"
  1371.       McGraw-Hill, 1978. 446 pages. ISBN 0-07-001115-X
  1372.            Discusses some of the fundamental issues involved in
  1373.            the implemention of Lisp.  
  1374.  
  1375.    2. Samuel Kamin
  1376.       "Programming Languages, An Interpreter-Based Approach"
  1377.       Addison-Wesley, Reading, Mass., 1990. ISBN 0-201-06824-9
  1378.            Includes sources to several interpreters for Lisp-like languages.
  1379.            The source for the interpreters in the book is available
  1380.            by anonymous FTP from 
  1381.               a.cs.uiuc.edu:/pub/kamin/kamin.distr/
  1382.           Tim Budd reimplemented the interpreters in C++, and has made
  1383.           them available by anonymous ftp from 
  1384.               cs.orst.edu:/pub/budd/kamin/
  1385.  
  1386.    3. Sharam Hekmatpour
  1387.       "Lisp: A Portable Implementation"
  1388.       Prentice Hall, 1985. ISBN 0-13-537490-X.
  1389.            Describes a portable implementation of a small dynamic
  1390.            Lisp interpreter (including C source code). 
  1391.  
  1392.    4. Peter Henderson
  1393.       "Functional Programming: Application and Implementation"
  1394.       Prentice-Hall (Englewood Cliffs, NJ), 1980. 355 pages.
  1395.  
  1396.    5. Peter M. Kogge
  1397.       "The Architecture of Symbolic Computers"
  1398.       McGraw-Hill, 1991. ISBN 0-07-035596-7.
  1399.            Includes sections on memory management, the SECD and
  1400.            Warren Abstract Machines, and overviews of the various
  1401.            Lisp Machine architectures.
  1402.    
  1403.    6. Daniel P. Friedman, Mitchell Wand, and Christopher T. Haynes
  1404.       "Essentials of Programming Languages"
  1405.       MIT Press, 1992, 536 pages. ISBN 0-262-06145-7.
  1406.            Teaches fundamental concepts of programming language
  1407.            design by using small interpreters as examples. Covers
  1408.            most of the features of Scheme. Includes a discussion
  1409.            of parameter passing techniques, object oriented languages,
  1410.            and techniques for transforming interpreters to allow
  1411.            their implementation in terms of any low-level language.
  1412.            Also discusses scanners, parsers, and the derivation of
  1413.            a compiler and virtual machine from an interpreter.
  1414.            Includes a few chapters on converting code into a
  1415.            continuation passing style.
  1416.            Source files available by anonymous ftp from 
  1417.               cs.indiana.edu:/pub/eopl/ [129.79.254.191].
  1418.  
  1419.    7. Peter Lee, editor, "Topics in Advanced Language Implementation",
  1420.       The MIT Press, Cambridge, Mass., 1991.
  1421.            Articles relevant to the implementation of functional
  1422.            programming languages.
  1423.  
  1424.    8. Also see the proceedings of the biannual ACM Lisp and Functional
  1425.       Programming conferences, the implementation notes for CMU Common Lisp,
  1426.       Norvig's book, and SICP (Abelson & Sussman).
  1427.  
  1428.    9. Christian Queinnec
  1429.       "Les Langages Lisp"
  1430.       InterEditions (in French), 1994. 500 pages.
  1431.       ISBN 2-7296-0549-5, 61-2448-1. (?)
  1432.  
  1433.       The book covers Lisp, Scheme and other related dialects,
  1434.       their interpretation, semantics and compilation.
  1435.  
  1436.       All of the programs described in the book are available by
  1437.       anonymous ftp from
  1438.          ftp.inria.fr:/INRIA/Projects/icsla/Books/LiSP94Sep05.tar.gz
  1439.       For more information, see the book's URL
  1440.          file://ftp.inria.fr/INRIA/Projects/icsla/WWW/LiSP.html
  1441.       or contact the author at Christian.Queinnec@inria.fr
  1442.  
  1443. ----------------------------------------------------------------
  1444. Subject: [1-5] What is the "minimal" set of primitives needed for a Lisp
  1445.                interpreter? 
  1446.  
  1447. Many Lisp functions can be defined in terms of other Lisp functions.
  1448. For example, CAAR can be defined in terms of CAR as
  1449.    (defun caar (list) (car (car list)))
  1450. It is then natural to ask whether there is a "minimal" or smallest set
  1451. of primitives necessary to implement the language. 
  1452.  
  1453. There is no single "best" minimal set of primitives; it all depends on
  1454. the implementation. For example, even something as basic as numbers
  1455. need not be primitive, and can be represented as lists. One possible
  1456. set of primitives might include CAR, CDR, and CONS for manipulation of
  1457. S-expressions, READ and PRINT for the input/output of S-expressions
  1458. and APPLY and EVAL for the guts of an interpreter.  But then you might
  1459. want to add LAMBDA for functions, EQ for equality, COND for
  1460. conditionals, SET for assignment, and DEFUN for definitions. QUOTE
  1461. might come in handy as well. If you add more specialized datatypes,
  1462. such as integers, floats, arrays, characters, and structures, you'll
  1463. need to add primitives to construct and access each.
  1464.  
  1465. AWKLisp is a Lisp interpreter written in awk, available by anonymous
  1466. ftp from ftp.cs.cmu.edu:/user/ai/lang/lisp/impl/awk/. It has thirteen
  1467. built-in functions: CAR, CDR, CONS, EQ, ATOM, SET, EVAL, ERROR, QUOTE,
  1468. COND, AND, OR, LIST. 
  1469.  
  1470. A more practical notion of a "minimal" set of primitives might be to
  1471. look at the implementation of Scheme. While many Scheme functions can
  1472. be derived from others, the language is much smaller than Common Lisp.
  1473. See Dybvig's PhD thesis, 
  1474.    R. Kent Dybvig, "Three Implementation Models for Scheme", Department
  1475.    of Computer Science Technical Report #87-011, University of North
  1476.    Carolina at Chapel Hill, Chapel Hill, North Carolina, April 1987.
  1477. for a justification of a particularly practical minimal set of
  1478. primitives for Scheme.
  1479.  
  1480. In a language like Common Lisp, however, there are a lot of low-level
  1481. primitive functions that cannot be written in terms of the others,
  1482. such as GET-UNIVERSAL-TIME, READ-CHAR, WRITE-CHAR, OPEN, and CLOSE,
  1483. for starters.  Moreover, real Common Lisp implementations are often
  1484. built upon primitives that aren't part of the language, per se, and
  1485. certainly not intended to be user-accessible, such as SYS:%POINTER-REF.
  1486.  
  1487. Beside the references listed in [1-4], some other relevant references
  1488. include:  
  1489.  
  1490.     McCarthy, John, "Recursive Functions of Symbolic Expressions and
  1491.     their Computation by Machine, Part I", CACM 3(4):185-195, April 1960.
  1492.        [Defines five elementary functions on s-expressions.]
  1493.  
  1494.     McCarthy, John, "A Micro-Manual for Lisp -- not the whole Truth",
  1495.     ACM SIGPLAN Notices, 13(8):215-216, August 1978.
  1496.        [Defines the Lisp programming language in 10 rules and gives
  1497.         a small interpreter (eval) written in this Lisp.]
  1498.  
  1499.     McCarthy, John, et al., "LISP 1.5 Programmer's Manual", 2nd edition,
  1500.     MIT Press, 1965, ISBN 0-262-13011-4 (paperback).  
  1501.        [Gives five basic functions, CAR, CDR, CONS, EQ, and ATOM.
  1502.         Using composition, conditional expressions (COND), and
  1503.         recursion, LAMBDA, and QUOTE, these basic functions may be used
  1504.         to construct the entire class of computable functions of
  1505.         S-expressions. Gives the functions EVAL and APPLY in
  1506.         M-expression syntax.] 
  1507.  
  1508.     Abelson and Sussman's SICP, especially chapters 4 and 5 on the
  1509.     implementation of meta-circular and explicit-control evaluators.
  1510.  
  1511.     Steele and Gabriel's "The Evolution of LISP".
  1512.  
  1513. ----------------------------------------------------------------
  1514. Subject: [1-6]  What does CLOS, PCL, X3J13, CAR, CDR, ... mean? 
  1515.  
  1516. Glossary of acronyms:
  1517.    CAR             Originally meant "Contents of Address portion of Register",
  1518.                    which is what CAR actually did on the IBM 704.
  1519.    CDR             Originally meant "Contents of Decrement portion of 
  1520.                    Register", which is what CDR actually did
  1521.                    on the IBM 704. Pronounced "Cudder" /kUdd@r/ (as in "a cow
  1522.                    chews its cdr"). The first syllable is pronounced
  1523.                    like "could". 
  1524.    LISP            Originally from "LISt Processing"
  1525.    GUI             Graphical User Interface
  1526.    CLOS            Common Lisp Object System. The object oriented
  1527.                    programming standard for Common Lisp. Based on
  1528.                    Symbolics FLAVORS and Xerox LOOPS, among others.
  1529.                    Pronounced either as "See-Loss" or "Closs". See also PCL.
  1530.    PCL             Portable Common Loops. A portable CLOS implementation.
  1531.                    Available by anonymous ftp from parcftp.xerox.com:pcl/.
  1532.    LOOPS           Lisp Object Oriented Programming System. A predecessor
  1533.                    to CLOS on Xerox Lisp machines.
  1534.    X3J13           Subcommittee of the ANSI committee X3 which is
  1535.                    working on the ANSI Standardization of Common Lisp.
  1536.    ANSI            American National Standards Institute
  1537.    dpANS           draft proposed American National Standard (what an ANS
  1538.                    is called while it's in the public review stage of
  1539.                    standardization).
  1540.    CL              Common Lisp
  1541.    SC22/WG16       The full name is ISO/IEC JTC 1/SC 22/WG 16. It stands
  1542.                    for International Organization for Standardization/
  1543.                    International Electrotechnical Commission, Joint
  1544.                    Technical Committee 1 Subcommittee 22 (full name
  1545.                    "Information Technology -- Programming Languages
  1546.                    and their Environments"), Working Group 16.  This
  1547.                    long-winded name is the ISO working group working
  1548.                    on an international Lisp standard, (i.e., the ISO
  1549.                    analogue to X3J13). 
  1550.    CLtL1           First edition of Guy Steele's book, 
  1551.                    "Common Lisp the Language". 
  1552.    CLtL2           Second edition of Guy Steele's book,
  1553.                    "Common Lisp the Language". 
  1554.  
  1555. ----------------------------------------------------------------
  1556. Subject: [1-7] Lisp Job Postings
  1557.  
  1558. The LISP-JOBS mailing list exists to help programmers find Lisp
  1559. programming positions, and to help companies with Lisp programming
  1560. positions find capable Lisp programmers. (Lisp here means Lisp-like
  1561. languages, including Scheme.)
  1562.  
  1563. Material appropriate for the list includes Lisp job announcements and
  1564. should be sent to ai+lisp-jobs@cs.cmu.edu. Resumes should NOT be sent to
  1565. the list. 
  1566.  
  1567. [Note: The 'ai+' part of the mailing list name is used for directing
  1568. submissions to the appropriate mail-server. The list is NOT restricted
  1569. to AI-related Lisp jobs -- all Lisp job announcements are welcome.]
  1570.  
  1571. As a matter of policy, the contents of this mailing list is
  1572. considered confidential and will not be disclosed to anybody.
  1573.  
  1574. To subscribe, send a message to ai+query@cs.cmu.edu with
  1575.    subscribe lisp-jobs <First Name> <Last Name>, <Affiliation/Organization>
  1576. in the message body. 
  1577.  
  1578. (If your mailer objects to the "+", send subscription requests to
  1579. "ai+query"@cs.cmu.edu, job announcements to "ai+lisp-jobs"@cs.cmu.edu, etc.)  
  1580.  
  1581. For help on using the query server, send mail to ai+query@cs.cmu.edu with
  1582.    help
  1583. in the message body.
  1584.  
  1585. If you have any other questions, please send them to ai+@cs.cmu.edu
  1586.  
  1587. ----------------------------------------------------------------
  1588.  
  1589. ;;; *EOF*
  1590.