LISP - destructive and non-destructive constructs

I would not interpret too much into the word 'destructive'.

In list processing, a destructive operation is one that potentially changes one or more of the input lists as a visible side effect.

Now, you can widen the meaning to operations over arrays, structures, CLOS objects, etc. You can also call variable assignment 'destructive' and so on.

In Common Lisp, it makes sense to talk about destructive operations over sequences (which are lists, strings, and vectors in general) and multi-dimensional arrays.


Practical Common Lisp distinguishes two kinds of destructive operations: for-side-effect operations and recycling operations.

set is destructive and for-side-effect: it always modifies its first argument. Beware, that it changes the binding for a symbol, but not the thing currently bound to that symbol. setf can change either bindings or objects in-place.

By contrast, nreverse is recycling: it is allowed to modify its argument list, although there's no guarantee that it will, so it should be used just like reverse (take the return value), except that the input argument may be "destroyed" and should no longer be used. [Scheme programmers may call this a "linear update" function.]