[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Copying a CLOS Instance



Given an instance is there a CLOS method to copy it?
In the XEROX release of PCL we had following cludge..

(defmethod COPY-INSTANCE ((obj T))
  (let ((new (pcl::make-instance (class-name (class-of obj))))
        (islots (pcl::wrapper-instance-slots-layout
              (pcl::class-wrapper (class-of obj)))))
    (dolist (slot islots)
      (when (slot-boundp obj slot)
        (setf (slot-value new slot)
              (slot-value obj slot))))
    new))

With the native implementation of CLOS (without metaclass fascility)in
the Allegro2.0b1 Common Lisp, such a hack will not work.

-Dattatraya Shetti
Mail address: shetti@ssdc.honeywell.com