Hi,
I'm not sure if I get your point, but if you only want to use one of the
classes B or C, just instantiate only one.
(defclass a () ())
(defclass b (a)())
(defclass c (a)())
(setq der (make-instance (if (test-to-decide-which-class) 'b 'c))
if you want to define an own class 'd and want to decide from which other
class you want to inherit, you can do the same trick at the class meta
level.
first define
(defclass d ())
with an empty inheritance list or the class of your choice. later on, when
you see which class fits your need, do
a (change-class ...) to switch to the other one. All living instances will
automatically be changed on next access.
There is an interesting method (update-instance-for-different-class ...)
with which you can transform the slot values on the fly from one class
instance to the other. It's a nice exercise to fiddle out how that crazy
thing is used. :)))
that's the big secret about CLOS: you can smoothly work on the meta level.
welcome in the world of lisp
- stefan
----------------------------------------------------------------------------
----------------
Dr. Stefan K. Bamberger,
Siemens AG, A&D AS E 213 phone:
++49-721-595-2568
76181 Karlsruhe fax:
++49-721-595-2022
Germany
> -----Ursprüngliche Nachricht-----
> Von: Antoine Clanche <bordeaux.inra.fr] at [SMTP:clanche>
> Gesendet am: Dienstag, 22. Juni 1999 15:49
> An: <cs.berkeley.edu at allegro-cl>
> Betreff: Delegation (assignment)
>
> Hello everybody,
>
> I'm a french new user of Allegro CL 3.0 for Windows.
>
> I'm trying to create a class D so that every instance of that class can be
> an instance of the classes B or C (see the next graph).
>
> class A
> |
> ---------------------
> | |
> class B class C
>
>
> Each instance of class D is an instance of class B or an instance of class
> C.
>
> I asked my if I really have to do an inheritance of B and C, because in
> that class D: I don't need other particulat methods that don't exist in B
> or C.
>
> With C++ or Java, I would have used the "delegation" (or assignment) and
> so
> I should'nt have used a multiple inheritance.
> But, I don't find any documentation about that possibility in Allegro CL.
>
> If, by fortune, you met that situation, please tell me how you've succeded
> !!
>
> Every help woud be marvellous.
>
> A young object-lisper.
>
>
>
>
>
> Antoine Clanche
> DESS Genie Logiciel
> <bordeaux.inra.fr at clanche>
> tel: 05-56-84-32-95