What is the difference between \"set\", \"setq\", and \"setf\" in Common Lisp?
setq
is just like set
with a quoted first arg -- (set 'foo '(bar baz))
is just like (setq foo '(bar baz))
. setf
, on the other hand, is subtle indeed -- it's like an "indirection". I suggest http://www.n-a-n-o.com/lisp/cmucl-tutorials/LISP-tutorial-16.html as a better way to get started understanding it than any answer here can give... in short, though, setf
takes the first argument as a "reference", so that e.g. (aref myarray 3)
will work (as the first arg to setf
) to set an item inside an array.