Path: utzoo!attcan!uunet!decwrl!ucbvax!agate!linus!linus!john From: john@linus.mitre.org (John D. Burger) Newsgroups: comp.lang.lisp Subject: Re: CLOS questions Message-ID: <124464@linus.mitre.org> Date: 25 Oct 90 20:40:46 GMT References: <28175@bellcore.bellcore.com> <2726886C.2C1B@wilbur.coyote.trw.com> Reply-To: john@mitre.org Organization: The MITRE Corporation, Bedford MA Lines: 42 The reason a new class has to be created when you want to inherit from two or more classes is that CLOS requires you to define the ORDER of the inheritance. Thus if # is an instance of both # and #, it's necessary to know the order in which # should inherit from these classes. This must be done in CLOS by defining a NEW class, say #, whose DIRECT-SUPERCLASSES slot dictates the order of inheritance. scott@alice.coyote.trw.com (Scott Simpson) writes: >The problem is that you want to reclassify an object after creation >time. The only way I know of doing this is to create a brand new >object in a different class. Actually, one can use CHANGE-CLASS to ``coerce'' an instance from its current class to a new one. Thus (SETF FRED (MAKE-INSTANCE 'STUDENT :NAME "Fred")) # (CLASS-OF FRED) # (CHANGE-CLASS FRED 'ATHLETE) # (CLASS-OF FRED) # Note that Fred is the exact same object. It's fairly easy to write CLOS code to cons up new mixtures of existing classes when necessary. For instance, posit a function FIND-MIXTURE, which takes any number of classes as arguments, and finds or creates a new class with exactly those supers. Thus (FIND-MIXTURE 'STUDENT 'ATHLETE) would create a new class, perhaps called STUDENT-ATHLETE, assuming no such class already existed. Then one could call CHANGE-CLASS on Fred and this new class, whenever it became apparent that Fred was not just a student. -- John Burger john@mitre.org "You ever think about .signature files? I mean, do we really need them?" - alt.andy.rooney