Changeset 3458
- Timestamp:
- 2015-09-05T09:45:08-07:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/f4grobner/ring.lisp
r3440 r3458 63 63 "SCALAR-COEFF" 64 64 "INSERT-ITEM" 65 "APPEND-ITEM" 66 "COPY-INSTANCE") 65 "APPEND-ITEM") 67 66 (:shadowing-import-from 68 67 #+openmcl-native-threads #:ccl … … 233 232 (defgeneric append-item (self item)) 234 233 235 ;; Source: http://stackoverflow.com/questions/11067899/is-there-a-generic-method-for-cloning-clos-objects236 ;; NOTE: This is a shallow copy. Add an around method for classes which need deep copy of the slots.237 (defgeneric copy-instance (object &rest initargs &key &allow-other-keys)238 (:method ((object cons) &rest initargs &key &allow-other-keys)239 (copy-seq object))240 (:documentation "Makes and returns a shallow copy of OBJECT.241 242 An uninitialized object of the same class as OBJECT is allocated by243 calling ALLOCATE-INSTANCE. For all slots returned by244 CLASS-SLOTS, the returned object has the245 same slot values and slot-unbound status as OBJECT.246 247 REINITIALIZE-INSTANCE is called to update the copy with INITARGS.")248 (:method ((object standard-object) &rest initargs &key &allow-other-keys)249 (let* ((class (class-of object))250 (copy (allocate-instance class)))251 (dolist (slot-name (mapcar #'slot-definition-name (class-slots class)))252 (when (slot-boundp object slot-name)253 (setf (slot-value copy slot-name)254 (slot-value object slot-name))))255 (apply #'reinitialize-instance copy initargs))))256 234 257 235 #|
Note:
See TracChangeset
for help on using the changeset viewer.