Re: class precedence list

From: Erick Gallesio <>
Date: Wed, 3 Nov 1999 16:01:41 +0100 (CET)


I *really apologize* for the long delay I took to answer but I'm here
again now!

> The compute-cpl procedure I proposed in a previous mail solved my
> specific problems on class precedence, but is not really satisfactory.
> For example, it is not always possible to explicitly specify the order
> between two superclasses. Furthermore, the algorithm doesn't work "by
> level" like the original STklos algorithm.
> Ken Anderson suggested reading a paper on class precedence algorithms
> in OOPSLA'96 proceedings. The paper can also be found here:
> The
> authors propose two algorithms with the important property of
> "monotonicity". The original STklos algorithm is not monotonic on
> occasion. Yet, neither of the two algorithms in the paper seems to
> work by level (but this property still needs to be defined in a formal
> way).

I agree that this notion of "by level" is not clear at all ;-) But the
things that I wanted to avoid were the kind of things provided by CLOS
and which are cited in the paper. The notion of monotonicity is clean
and I suppose inmho that it what a user generally want.

> So, following the paper, I wrote another compute-cpl procedure which,
> I hope, is monotonic (no formal proof of that point) and works by
> level. Any comment would be appreciated.
> [ algorithm deleted]

I have tried your algorithm for a while now and I have even integrated
it in my version of STklos. It is far better than the original STklos
algorithm. However there are points which are not clear for me (they
are all related with "transitivity edge")

For instance, when you define

    (define (cpl C) (map class-name (class-precedence-list c)))

    (define-class B () ())
    (define-class DB (B) ())
    (define-class WB (B) ())
    (define-class EL (DB) ())
    (define-class SMH (DB) ())
    (define-class PWB (EL WB) ())
    (define-class SC (SMH) ())
    (define-class P (PWB SC DB WB) ()) ; preferring DB over WB

    (cpl p) ==> (p pwb sc el smh db wb b <object> <top>)

As stated in the paper, using a transitive edge can be used to have
fine control over the inheritance mechanism. It seems to me that it
should be
       (p pwb sc db wb ...)

I suppose that we can easily be non monotonic in this case, but since
this is the user which has fixed the inheritance to use, it is
probably a good thing to not change his/her choices. Of course it is
always possible to change explicitly the cpl by hand but it is probably
not suitable for common uses. What do you think of that?

BTW, I have tried to modify your algorithm for taking into account
this and was not able to do so without breaking the rest. Should it be
easy to modify it to do so?

                -- Erick
Received on Wed Nov 03 1999 - 17:01:08 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST