From: Chris Perkins
Subject: Adding a new superclass to an instance?
Date: 
Message-ID: <Bqak8.80$kl3.83292@news.uswest.net>
Is it possible to add a new superclass to an already created instance of
some class, without modifying the original class?

It seems like it might be possible to dynamically define a new class that
has the superclasses of the class of the original object and the newly
desired superclass, and then call change-class on the object with this new
class.  Is that correct?  Is there a simpler way?

Thanks,

Chris Perkins

From: Kent M Pitman
Subject: Re: Adding a new superclass to an instance?
Date: 
Message-ID: <sfwofhqg1bs.fsf@shell01.TheWorld.com>
"Chris Perkins" <········@medialab.com> writes:

> Is it possible to add a new superclass to an already created instance of
> some class, without modifying the original class?

Superclasses are attributes of the instance's class, so that's not a 
meaningful thing to ask for.  (Merely because your terminology is confused.)
Creating an instance does not copy the superclasses into the instance;
the instance references its class by pointer-reference so a change to the
superclasses of one instance's class is a change to the superclasses of all
instances.
 
> It seems like it might be possible to dynamically define a new class that
> has the superclasses of the class of the original object and the newly
> desired superclass, and then call change-class on the object with this new
> class.  Is that correct?  

Sure.  That's quite possible. 

> Is there a simpler way?

Not the way you've set up the problem.  How much easier could it be?
The instance will need a class.  You've explained how to make it.
You've explained how to change the instance's class to the new class.
It's only a two-step process as you describe it and you can't leave out
either part.  How much easier can it get??
From: Kenny Tilton
Subject: Re: Adding a new superclass to an instance?
Date: 
Message-ID: <3C9156D2.991CC46A@nyc.rr.com>
Chris Perkins wrote:
> 
> Is it possible to add a new superclass to an already created instance of
> some class, without modifying the original class?
> 
> It seems like it might be possible to dynamically define a new class that
> has the superclasses of the class of the original object and the newly
> desired superclass, and then call change-class on the object with this new
> class.  Is that correct?  Is there a simpler way?

Perhaps, if this package does what you want (I think it does):

  
http://www.iit.nrc.ca/~martin/capabilities_web/docs/capabilities_home.html

   "Capabilities is a package of CLOS programming primitives providing
dynamic addition and removal of coherent chunks of structure and
function to loose aggregates of interacting object instances. A
capability is added to a collection of objects by changing one or more
instances' classes, mixing in additional superclasses to those already
present. The newly mixed instances may then interact in new ways, using
new methods, new slots, and new objects created during initialization
and method execution. The capability may subsequently be removed,
restoring the objects to their previous structure and function."


-- 

 kenny tilton
 clinisys, inc
 ---------------------------------------------------------------
 "Be the ball...be the ball...you're not being the ball, Danny."
                                               - Ty, Caddy Shack
From: Chris Perkins
Subject: Re: Adding a new superclass to an instance?
Date: 
Message-ID: <78qk8.40$u37.40908@news.uswest.net>
Kenny,

Thanks - that's a great link.   It not only answered my immediate question,
but the whole discussion of "capabilities" makes for great reading.   (lisp
rocks!)

Chris


"Kenny Tilton" <·······@nyc.rr.com> wrote in message
······················@nyc.rr.com...
>
>
> http://www.iit.nrc.ca/~martin/capabilities_web/docs/capabilities_home.html
>
>    "Capabilities is a package of CLOS programming primitives providing
> dynamic addition and removal of coherent chunks of structure and
> function to loose aggregates of interacting object instances. A
> capability is added to a collection of objects by changing one or more
> instances' classes, mixing in additional superclasses to those already
> present. The newly mixed instances may then interact in new ways, using
> new methods, new slots, and new objects created during initialization
> and method execution. The capability may subsequently be removed,
> restoring the objects to their previous structure and function."
>
>
> --
>
>  kenny tilton
>  clinisys, inc
>  ---------------------------------------------------------------
>  "Be the ball...be the ball...you're not being the ball, Danny."
>                                                - Ty, Caddy Shack