[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Copying a CLOS Instance
- To: "Shetti Dattatraya" <Shetti_Dattatraya@ssdc.honeywell.com>
- Subject: Re: Copying a CLOS Instance
- From: Bill St. Clair <bill>
- Date: Mon, 24 Jun 91 13:00:06 -0400
- Cc: info-macl@cambridge.apple.com
- In-reply-to: Your message of 24 Jun 91 11:21:06 +0800. <9106241644.AA19174@lutsen.hi-csc.honeywell.com>
Date: 24 Jun 91 11:21:06 U
From: "Shetti Dattatraya" <Shetti_Dattatraya@ssdc.honeywell.com>
Subject: Copying a CLOS Instance
Return-Receipt-To: Shetti_Dattatraya@ssdc.honeywell.com
Priority: Normal
To: info-macl@cambridge.apple.com
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
The following will work for instances which are not generic functions.
It will be included as part of the final release of MCL 2.0
---------------------------------------------------------------------------
(in-package :ccl)
(export 'copy-instance)
(defmethod copy-instance ((instance standard-object))
(copy-uvector (%maybe-forwarded-instance instance)))