From: Ibrahim H. Seyrek
Subject: how to add a slot to an already defined class
Date: 
Message-ID: <31EC2A75.41C6@dmi.stevens-tech.edu>
I am trying to write a function which adds a slot (with its readers,
writers, etc.) to a previously defined class. Can anyone tell me if  
there is a way of doing that? I will appreciate any help.
From: Christian Rathke
Subject: Re: how to add a slot to an already defined class
Date: 
Message-ID: <rathke-1707961013070001@news>
In article <·············@dmi.stevens-tech.edu>, "Ibrahim H. Seyrek"
<·······@dmi.stevens-tech.edu> wrote:

>I am trying to write a function which adds a slot (with its readers,
>writers, etc.) to a previously defined class. Can anyone tell me if  
>there is a way of doing that? I will appreciate any help.

Use the generic function 'reinitialize-instance' on the class.  Here is an
example of how to do it:

(defclass testclass () ((slot-a)))

and then:

(reinitialize-instance (find-class 'testclass)
   :direct-slots '((:name slot-a)
                   (:name slot-b :readers (read-b) :writers (write-b))))

The argument list of the direct-slots initarg is a list of so-called
'canonicalized slot specification.'  Note that you have to mention all
direct slots (old or new) of the reinitialized class.  Other properties
such as super classes, default initargs, etc. are left unchanged.

   -Christian

-- 
Christian Rathke                        ······@informatik.uni-stuttgart.de
Institut fuer Informatik, Universitaet Stuttgart   Tel: (+49 711) 7816-436
Breitwiesenstr. 20-22, D-70565 Stuttgart, Germany  Fax: (+49 711) 7816-340
http://www.informatik.uni-stuttgart.de/ifi/is/christian.html