All Manuals > LispWorks® User Guide and Reference Manual > 31 The CLOS Package

copy-standard-object Function

Summary

Creates a new copy of a CLOS object.

Package

clos

Signature

copy-standard-object source => target

Arguments
source
Values
target
Description

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.

See also

replace-standard-object


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:25