Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!europa.eng.gtefsd.com!news.mathworks.com!udel!news.sprintlink.net!EU.net!Germany.EU.net!news.dfn.de!news.belwue.de!news.informatik.uni-stuttgart.de!herczeg
From: herczeg@diana.informatik.uni-stuttgart.de (Juergen Herczeg)
Subject: Re: Copying CLOS instance?
In-Reply-To: geddis@CS.Stanford.EDU's message of 2 Nov 1994 23:53:11 GMT
Message-ID: <HERCZEG.94Nov4090931@diana.informatik.uni-stuttgart.de>
Lines: 30
Sender: news@informatik.uni-stuttgart.de
Organization: Informatik, University of Stuttgart, Germany
References: <3998p8$es5@Times.Stanford.EDU>
Date: Fri, 4 Nov 1994 08:09:28 GMT

In article <3998p8$es5@Times.Stanford.EDU> geddis@CS.Stanford.EDU (Don Geddis) writes:

   If you have a defstruct class, and then an object that's an instance of it,
   you get for free a "copy-<class>" function to make a copy of the instance.
   I want to do the same thing with a CLOS instance, but sadly there appears to
   be no corresponding copy function.  I would guess that somehow using the
   Meta Object Protocol I'd be able to write such a copy function, but the MOP
   is well beyond my current understanding.  Does anyone know a simple way to
   do this?

We have implemented a utility for copying CLOS objects (as part of the
XIT system).  You will find the ftp address in the lisp FAQ on FTP
Resources (look for "copy-objects").

The methods of the generic copy function may be specialized to perform
either a shallow-copy or a deep-copy, i.e. copy the slot values of an
object recursively.  deep-copy also handles circular references.

We use this function for copying graphical objects in the XIT user
interface toolkit.

Juergen
--

==============================================================================
Juergen Herczeg                    E-Mail: herczeg@informatik.uni-stuttgart.de
Research Group DRUID
Computer Science Department, University of Stuttgart   Phone: +49 711 7816 364
Breitwiesenstr. 20-22, D-70565 Stuttgart, Germany      Fax:   +49 711 7816 340
==============================================================================
