Peter Seibel in Practical Common Lisp Ch 6. Variables, footnote 4, mentions that integers and characters are immutable. (To this short list, sds at Nondestructive setf? adds pathnames.)
Does this mean that non-integer number types like complex
, ratio
, and float
are actually mutable objects; that is, have components that can be destructively modified? For example, is it possible to change the real-part
of a complex number? (However, the usual method--e.g., (setf (real-part cplx) 2)
does not work.) Or perhaps is a complex number an immutable object, but with some special properties not shared by integer
?
Also, is it correct to say that the immutable objects present in more complex mutable objects are not copied during the various copy-
functions (and other functions like remove
that copy their arguments); and that only the structure provided by the enclosing mutable objects is copied, while retaining the identical immutable objects?