Changeset 2868 for branches/f4grobner
- Timestamp:
- 2015-06-21T11:25:07-07:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/f4grobner/ring.lisp
r2867 r2868 199 199 (defgeneric append-item (self item)) 200 200 201 ;; Source: http://stackoverflow.com/questions/11067899/is-there-a-generic-method-for-cloning-clos-objects 202 (defgeneric copy-instance (object &rest initargs &key &allow-other-keys) 203 (:documentation "Makes and returns a shallow copy of OBJECT. 204 205 An uninitialized object of the same class as OBJECT is allocated by 206 calling ALLOCATE-INSTANCE. For all slots returned by 207 CLASS-SLOTS, the returned object has the 208 same slot values and slot-unbound status as OBJECT. 209 210 REINITIALIZE-INSTANCE is called to update the copy with INITARGS.") 211 (:method ((object standard-object) &rest initargs &key &allow-other-keys) 212 (let* ((class (class-of object)) 213 (copy (allocate-instance class))) 214 (dolist (slot-name (mapcar #'sb-mop:slot-definition-name (sb-mop:class-slots class))) 215 (when (slot-boundp object slot-name) 216 (setf (slot-value copy slot-name) 217 (slot-value object slot-name)))) 218 (apply #'reinitialize-instance copy initargs))))
Note:
See TracChangeset
for help on using the changeset viewer.