From: Michael Hudson
Subject: MOP(?) question: dynamically rearranging bases
Date: 
Message-ID: <7h3el97qhbt.fsf@pc150.maths.bris.ac.uk>
I was wondering if CLOS (possibly augmented with the MOP) allows one
to shuffle the bases of a class.  From a little online searching, it
seems not -- I can find no mention of a (setf
class-direct-superclasses) function or the like.

Does anyone know different?

[The reason for asking is that I'm implementing roughly the equivalent
for Python, and was wondering what the MOP might do in the face of CPL
conflicts]

Cheers,
M.

-- 
  You owe The Oracle a TV with an 'intelligence' control - I've 
  tried 'brightness' but that didn't work.
                                      -- Internet Oracularity #1192-01
From: Tim Bradshaw
Subject: Re: MOP(?) question: dynamically rearranging bases
Date: 
Message-ID: <ey3adjvp0ub.fsf@cley.com>
* Michael Hudson wrote:
> I was wondering if CLOS (possibly augmented with the MOP) allows one
> to shuffle the bases of a class.  From a little online searching, it
> seems not -- I can find no mention of a (setf
> class-direct-superclasses) function or the like.

Yes. If you redefine a class with a different set of superclasses, or
the same set in a different order, then the CPL will change
appropriately.  Standard CLOS only allows you do do this via the
DEFCLASS macro, but a MOP will provide a functional equivalent to
this.  I think in the AMOP MOP this would be done by ENSURE-CLASS or
ENSURE-CLASS-USING-CLASS, but it's not clear to me that you can't also
do it via REINITIALIZE-INSTANCE as well.

I haven't checked how much argument defaulting goes on (so, whether
you need to provide the other arguments to ENSURE-CLASS-USING-CLASS or
whether they get defaulted from the existing class), but something
like this should work (tested in one implementation, caveat lector):

(defclass foo ()())
(defclass bar ()())
(defclass hen (foo bar)
  ((x)))

(ensure-class-using-class (find-class 'hen) 'hen 
                          :direct-superclasses '(bar foo))

--tim