LISP has the setf
function to assign a value to a variable. Now I have been wondering about the function's name: The set
part is obvious, but what does the f
suffix stand for?

- 140,679
- 96
- 298
- 425
-
7+1 This is an interesting question. It's not necessarily a programming question, per se, (since it's not about how to **use** setf), but it's not one with an obvious answer, and understanding naming conventions and history can often help a programmer's mental model of the language. (Incidentally, the `q` in `setq` is easier. In older Lisps where using a symbol's `symbol-value` was more common, it was nice to abbreviate `(set 'foo …)` as `(setq foo …)` (so the q is for `quote`).) – Joshua Taylor May 22 '14 at 15:00
-
1Thanks for this nice comment :-)). To me as a LISP beginner some names are hard to grasp, another example is `evenp` and `oddp`: I just wonder what the `p` stands for, and it definitely helps memorizing functions if you really understand their names (and hence their meaning). – Golo Roden May 22 '14 at 17:03
-
5P stands for "predicate" – Joshua Taylor May 22 '14 at 17:10
-
2You might be interested in http://www.cliki.net/Naming+conventions, but note that it's got "generalized field for f in setf" – Joshua Taylor May 22 '14 at 17:57
-
Again, thanks a lot for pointing this out :-) – Golo Roden May 22 '14 at 20:57
1 Answers
The actual meaning of F is often forgotten. According to some sources, f suffix could stand for:
- Field (see for example this answer)
- Form (as seen in various teaching materials and manuals)
However, according to Gabriel and Steele's The Evolution of Lisp, SETF comes from Peter Deutsch's A Lisp Machine with Very Compact Programs (published in 1973) and F stands for function.
In this paper, Peter Deutsch wrote:
The SET function is extended so that so that if the first argument is a list
(fn argl ... argn)
rather than a variable, the function fn is called in "store" mode with argumentsargl ... argn
and newvalue (the second argument of SET). SETQ is also extended in the obvious way, but is not particularly useful. A more useful function is(SETFQ (fn argl ... argn) newvalue)
which quotes the function name and evaluates everything else. This allows RPLACA, for example, to be defined as(LAMBDA (X Y) (SETFQ (CAR X) Y))
.
(emphasis mine)
Gabriel and Steele explain how this became SETF:
This name was abbreviated to SETF in Lisp-Machine Lisp.

- 21,900
- 13
- 104
- 178

- 6,257
- 1
- 20
- 31
-
Thanks for pointing this out, now I know what terms to watch out for :-)! – Golo Roden May 22 '14 at 13:36
-
@GoloRoden There are 2 conflicting answers, how do you know this one is correct? – henginy May 22 '14 at 13:43
-
I can't *know* that it's correct, but I googled for both terms and found another (quite upvoted) [answer](http://stackoverflow.com/a/869693/1333873) that suggest that it's `field`, not `form`. Apart from that, this answer is more helpful as it also points out what the `q` stands for. – Golo Roden May 22 '14 at 13:46
-
Thanks for sharing the link. Now other people looking at this question can also know how. – henginy May 22 '14 at 13:55
-
4I corrected the answer using reputable sources. F stands for function, not form or field. – Paul Guyot May 22 '14 at 14:14