Search code examples
lispcommon-lisp

What does the f in setf stand for?


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?


Solution

  • 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 arguments argl ... 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.