1

When I was learning HTML it was very helpful for me to know that ol means ordered list, tr is table row, etc. Some of the lisp primitives/forms are easy: funcall should be function call, defmacro - define macro. Some are in the middle - incf is... increment... f??? But because common lisp is so old, this primitives/special forms/etc... don't seem to ring a bell. Can you guys, help me with figuring them out? And even more importantly: Where can I find an authoritative resource on learning the meaning/history behind each and every one of them? (I will accept an answer based on this second question)

The documentation doesn't help me too:

* (describe #'let)

#<CLOSURE (:SPECIAL LET) {10013DC6AB}>
  [compiled closure]

Lambda-list: (&REST ARGS)
Derived type: (FUNCTION (&REST T) NIL)
Documentation:
  T
Source file: SYS:SRC;COMPILER;INFO-FUNCTIONS.LISP

* (documentation 'let 'function)

"LET ({(var [value]) | var}*) declaration* form*

During evaluation of the FORMS, bind the VARS to the result of evaluating the
VALUE forms. The variables are bound in parallel after all of the VALUES forms
have been evaluated."

* (inspect 'let)

The object is a SYMBOL.
0. Name: "LET"
1. Package: #<PACKAGE "COMMON-LISP">
2. Value: "unbound"
3. Function: #<CLOSURE (:SPECIAL LET) {10013DC6AB}>
4. Plist: (SB-WALKER::WALKER-TEMPLATE SB-WALKER::WALK-LET)

What do the following lisp primitives/special forms/special operators/functions mean?

  • let, flet
  • progn
  • car
  • cdr
  • acc
  • setq, setf
  • incf

(write more in the comments so we can make a good list!)

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
anonymous
  • 1,522
  • 14
  • 24

2 Answers2

8
  • let: LET variable-name be bound to a certain value
  • flet: LET Function-name be bound to a certain function
  • progn: execute a PROGram sequence and return the Nth value (the last value)
  • car: Contents of the Address Register (historic)
  • cdr: Contents of the Decrement Register (historic)
  • acc: ACCumulator
  • setq: SET Quote, a variant of the set function, where in setq the user doesn't quote the variable
  • setf: SET Function quoted, shorter name of the original name setfq. Here the function/place is not evaluated.
  • incf: INCrement Function quoted, similar to setf. Increments a place.

Other conventions:

  • Macros / Special Forms who change a place should have an f at the end: setf, psetf, incf, decf, ...
  • Macros who are DEFining something should have def or define in front: defun, defmethod, defclass, define-method-combination...
  • Functions who are destructive should have an n in front, for Non-consing: nreverse, ...
  • Predicates have a p or -p at the end: adjustable-array-p, alpha-char-p,...
  • special variables have * at the front and back: *standard-output*, ...

There are other naming conventions.

Rainer Joswig
  • 136,269
  • 10
  • 221
  • 346
4
  • let: Well, that's a normal word, and is used like in maths ("let x = 3 in ...").
  • flet: I'd guess "function let", because that's what it does.
  • progn: This is probably related also to prog1 and prog2. I read is as "program whose nth form dictates the result value". The program has n forms, so it's the last one that forms the result value of the progn form.
  • car and cdr: "Contents address register" resp. "Contents decrement register". This is related to the IBM 704 which Lisp was originally implemented for.
  • setq: "set quote", originally an abbreviation for (set (quote *abc*) value).
  • setf: "set field", came up when lexical variables appeared. This is a good read on the set functions.

Where can I find an authoritative resource on learning the meaning/history behind each and every one of them?

The HyperSpec is a good place to start, and ultimately the ANSI standard. Though "Common Lisp The Language" could also shine some light on the history of some names.

(Oh, and you got defmacro wrong, that's "Definition for Mac, Read Only." ;) )

Community
  • 1
  • 1
Daniel Jour
  • 15,896
  • 2
  • 36
  • 63
  • Thanks! Of course I know the HyperSpec and Common Lisp The Language, but they don't seem to shed light on the history/meaning behind the operators :) I just checked about the official ANSI standard here: http://www.techstreet.com/standards/incits-226-1994-r1999?product_id=56214 and here http://webstore.ansi.org/RecordDetail.aspx?sku=INCITS+226-1994%5BS2008%5D it is both 60$ :( – anonymous Jun 16 '16 at 22:20
  • 2
    [The almost ANSI CL Standard](http://lispm.de/docs/Publications/Lisp%20Language%20Manuals/1994%20ANSI%20Common%20Lisp.pdf) – Rainer Joswig Jun 16 '16 at 23:03
  • 1
    @tsikov The hyperspec contains, within epsilon, the same text as the actual spec, so unless you want paper or an equivalent it's fine (and even if you do there are similarly substantively-identical pdfs around as Rainer has mentioned). To answer your question: I'm not aware of a definitive source and suspect there is none outside, perhaps, of the memories of some lisp hackers who were there and, perhaps, mailing-list archives. –  Jun 21 '16 at 15:02
  • Thanks, tfb. In that case, which answer should I accept? :) – anonymous Jun 22 '16 at 09:28