The function copy-standard-object
creates a new copy of the CLOS object source.
source must be of type standard-object
, excluding funcallable-standard-object and its subclasses, in particular it cannot be of type generic-function
.
The copying is shallow, that is only the actual values are copied, as if by
(dolist (slot instance-slots)
(setf (slot-value target slot)
(slot-value source slot)))
assuming no definition that affects what slot-value
and (setf slot-value)
do. However, copy-standard-object
bypasses the slot-value
mechanism and is much faster.
copy-standard-object
should be used on instances of user-defined classes which do not inherit from system-defined classes (other than standard-object
). If source is an instance of a system-defined class (or a subclass of a system-defined class) then target cannot be used as a functional object, but its slot values can be read safely. That may be useful for debugging.
LispWorks User Guide and Reference Manual - 13 Feb 2015