Mutating functions and effects in Common Lisp
Table of Contents
Mutating functions and effects in Common Lisp
The main function for mutating data is setf, and the main form for calling
side-effects is progn. But there are other forms which uses implicit progn as
part of it’s body or uses setf under the hood. It’s not always easy to know
when these forms are used.
Mutate variables
setfincfdecfsetq
Destructive counterparts of non-destructive list functions
These functions are prefixed with n.
nreversenconcnubstnunionnintersectionnset-difference
Other destructive list operations
These should have been prefixed with n, but are not due to historical reasons.
sortdelete(destructiveremove– should be callednremove)pushpop
Forms allowing more than one expression
While expressions with external effects are allowed everywhere, a good
indication that side-effect are supported is the usage of progn or variants
which allows more than one expression. The only reason to allow more than a
single form is to run effects and throw away the result.
prognprog1prog2blockprogprog*progvtagbody