The function replace-standard-object
replaces the values in the slots of the CLOS object target by the values of slots from the CLOS object source.
Only slots with allocation type :instance
are copied from source to target.
source and target must be of type standard-object
, excluding funcallable-standard-object and its subclasses, in particular they cannot be of type generic-function
. Moreover both must be of the same class, that is:
(eq (class-of target) (class-of source)) => t
The replacement 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, replace-standard-object
bypasses the slot-value
mechanism and is much faster.
replace-standard-object
should be used on instances of user-defined classes which do not inherit from system-defined classes (other than standard-object
). It should never be used on instances of system-defined classes and their subclasses.
LispWorks User Guide and Reference Manual - 20 Sep 2017