[cl-faq] FAQ tweaking, and a (real) answer to the SETF question

Larry Clapp larry at theclapp.org
Fri Dec 23 08:54:29 CST 2005


*** faq.txt.current	Tue Dec 20 17:09:19 2005
--- faq.txt	Fri Dec 23 09:46:42 2005
***************
*** 1,13 ****
  * Common Lisp FAQ
  
  \faq{
! \question{Why is it called "LET"?}
  \answer{Think of a mathematical proof - "Let x be the distance from origin ..."}
  }
  
  \faq{
! \question{Why is SETF called that?}
! \answer{}
  }
  
  \faq{
--- 1,63 ----
  * Common Lisp FAQ
  
  \faq{
! \question{Why is it called "\code{LET}"?}
  \answer{Think of a mathematical proof - "Let x be the distance from origin ..."}
  }
  
  \faq{
! \question{Why is \code{SETF} called that?}
! \answer{Peter Seibel once asked a similar question on comp.lang.lisp
! (http://groups.google.com/group/comp.lang.lisp/msg/ffad99a26dfa6b2e).  He
! received many good answers, but I liked Kent Pitman's the best
! (http://groups.google.com/group/comp.lang.lisp/msg/3a2a1d486f0dea91),
! excerpted here:
! 
!   A long time ago, Lisp was only dynamic.  \code{SET} and \code{SETQ} were
!   very similar then, because setting dynamic variables was the same as doing
!   what we now call 
! 
!    \code{(SETF (SYMBOL-VALUE 'VAR) 'VAL }
! 
!   At that time, we called that operation 
! 
!    \code{(SET 'VAR 'VAL)} 
! 
!   sometimes even written 
! 
!    \code{(SET' VAR 'VAL)} 
! 
!   but ultimately written 
! 
!    \code{(SETQ VAR VAL)} 
! 
!   And since it was rare to compute the value, most people only ever saw
!   \code{SETQ} used and never saw \code{SET} used. 
! 
!   With the introduction of lexical variables, assignment continued to use the
!   operator \code{SETQ}, but it was no longer equivalent to \code{SET'}. 
! 
!   Someone later invented \code{SETF} ("Set field") as a generic way of
!   assigning data structures, to mirror the l-value assignment of other
!   languages.  e.g., car(x) := y; would be written \code{(setf (car x) y)}.
!   For syntactic (if not semantic) symmetry, they made x := y be writable as
!   \code{(setf x y)}. 
! 
!   \code{GET} existed pretty much forever as a way of getting things from
!   property lists.  The assignment operator was \code{(PUTPROP sym val ind)}.
!   Some Lisp dialects used \code{GETPROP} instead of \code{GET}.   
! 
!   When \code{SETF} came along, \code{(PUTPROP x y z)} was subsumed by
!   \code{(SETF (GET x z) y)}, which most people considered more visually simple
!   but a better arg order. 
! 
!   People also started to think about the idea of \code{GET} being generalized
!   for so-called "disembodied property lists".  \code{GETF} was intended to be
!   the \code{GET}-like way to talk about the field of a property list,
!   independently of whether the property list was stored on a symbol's plist.
!   \code{(GETF (PLIST x) y)} was the same as \code{(GET x y)}; later
!   \code{PLIST} became \code{SYMBOL-PLIST}.
! }
  }
  
  \faq{
***************
*** 141,147 ****
  
  \faq{
  \question{Packages, symbols, export, import -- what's it all mean?}
! \answer{<short summary; link to Ron Garret's document}
  }
  
  \faq{
--- 191,197 ----
  
  \faq{
  \question{Packages, symbols, export, import -- what's it all mean?}
! \answer{<short summary; link to Ron Garret's document>}
  }
  
  \faq{
***************
*** 153,159 ****
  \question{Where is my compiler?  My debugger?  Where is my program running?}
  \answer{Lisp works quite differently to most languages that you may be
  familiar with, for example C has a very distinct cycle.  You edit some
! code, compile it with a seperate compiler and produce an executable. 
  You can then run that executable, perhaps with a debugger attached to
  it.  Modern IDEs smooth the distinctions between these steps, but
  under the hood they are still there.
--- 203,209 ----
  \question{Where is my compiler?  My debugger?  Where is my program running?}
  \answer{Lisp works quite differently to most languages that you may be
  familiar with, for example C has a very distinct cycle.  You edit some
! code, compile it with a separate compiler and produce an executable. 
  You can then run that executable, perhaps with a debugger attached to
  it.  Modern IDEs smooth the distinctions between these steps, but
  under the hood they are still there.
***************
*** 166,172 ****
  compiler.
  
  I have started thinking of my Lisp image as its own environment,
! almost a seperate little operating system.
  
  Interacting with the Lisp image is done via the Read-Eval-Print-Loop
  (REPL), which as the name implies, reads input, evaluates and then
--- 216,222 ----
  compiler.
  
  I have started thinking of my Lisp image as its own environment,
! almost a separate little operating system.
  
  Interacting with the Lisp image is done via the Read-Eval-Print-Loop
  (REPL), which as the name implies, reads input, evaluates and then
***************
*** 253,271 ****
  
  \faq{
  \question{What editors besides Emacs have facilities for programming in Lisp?}
! \answer{Vim is lisp-aware.  See my article at
! http://cybertiggyr.com/gene/15-vim/.  I give blanket permission for
! anything and everything in that article to be included wholesale in
! the FAQ.
  
  See also http://www.vim.org/scripts/script.php?script_id=221 for the
  closest thing to SLIME for Vim: VILisp.  VILisp basically automates
  the process of cut-and-paste from Vim into Lisp, and adds a few bells
! and whistles, but that's about it.}
  }
  
  \faq{
! \question{How do I do multiple statements in a row, in an IF?
  
      ;; Warning: Incorrect code!
      (if (test)
--- 303,323 ----
  
  \faq{
  \question{What editors besides Emacs have facilities for programming in Lisp?}
! \answer{Vim is lisp-aware.  See Larry Clapp's article at
! http://cybertiggyr.com/gene/15-vim/.
  
  See also http://www.vim.org/scripts/script.php?script_id=221 for the
  closest thing to SLIME for Vim: VILisp.  VILisp basically automates
  the process of cut-and-paste from Vim into Lisp, and adds a few bells
! and whistles, but that's about it.
! 
! Larry has started a Gardener's project
! (http://wiki.alu.org:80/Perl_interface_to_SLIME) to write a Perl module to
! talk to Swank.  As of this writing (12/19/05), it's about one day old.}
  }
  
  \faq{
! \question{How do I do multiple statements in a row, in an \code{IF}?
  
      ;; Warning: Incorrect code!
      (if (test)
***************
*** 278,284 ****
  }
  
  \answer{In general, wherever you can put a single expression, you can
! put a PROGN with multiple expressions.  So to solve this particular
  question,
  
      (if (test)
--- 330,336 ----
  }
  
  \answer{In general, wherever you can put a single expression, you can
! put a \code{PROGN} with multiple expressions.  So to solve this particular
  question,
  
      (if (test)
***************
*** 298,304 ****
        (t (statement3)
  	 (statement4)))
  
! Of course, COND also works with multiple tests.
  
  See the Hyperspec for \code{PROGN} and \code{COND}.
  }
--- 350,356 ----
        (t (statement3)
  	 (statement4)))
  
! Of course, \code{COND} also works with multiple tests.
  
  See the Hyperspec for \code{PROGN} and \code{COND}.
  }


More information about the cl-faq mailing list