[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dumb CLOS q? (Change-class)
- To: info-mcl@digitool.com
- Subject: Re: dumb CLOS q? (Change-class)
- From: Shannon V Spires <svspire@somnet.sandia.gov>
- Date: Thu, 20 Apr 1995 11:08:57 -0600 (MDT)
- Cc: missing@inch.com
- In-reply-to: <199504200500.BAA01285@digitool.com> from "info-mcl-digest-request@digitool.com" at Apr 20, 95 01:00:03 am
- Sender: owner-info-mcl@digitool.com
Ken Tilton writes:
> Is this a dum CLOS q?:
>
> How come #'change-class does not take a &rest arg? ie,
> multiple-inheritance change-class?
>
> Not that I need it (yet <g>), but it *has* crossed my mind. Granted, if
> one wants to do such a change-class, it is likely one would have
> actually defined a class inheriting that specific combo, but shucks, I
> was starting to think CL could do *anything*!
This isn't dumb at all; it's an issue that may be confusing to new CLOS
programmers. And you're already on the right track. CLOS instances are
strictly single-inheritance beasts. By that I mean that an instance is
always an instance of _exactly one_ class. Classes themselves may inherit
from multiple superclasses, but instances may not.
If you need to make instances that "inherit" from multiple classes on
the fly, the way you do it is to dynamically create a class that
inherits from the desired superclasses, and then make an instance of
it. (Try THAT in see-plus-plus!) AMOP (Gregor Kiczales et al, "The Art
of the Metaobject Protocol," MIT Press 1991--a volume that every CLOS
programmer should have nearby) gives an excellent example of this in
section 2.4.
--
Shannon Spires
svspire@sandia.gov