(rontolisp) docs
← cl Package Functions

copy-structure

(copy-structure structure)

Returns a fresh instance of structure's type (CLHS 18.3): the slots are freshly allocated, but their VALUES are shared with the original -- a shallow copy, so mutating a slot of the copy never touches the source and vice versa. It is the generic counterpart of the copy-<name> copier defstruct generates for one known type: that copier's tag is known at compile time and goes straight through the %obj-new instance constructor, while copy-structure reads its argument's own layout at run time, since the type is not known until then.

Mutating the copy leaves the original untouched, since only the slot storage is fresh: