Subject: CLOS: precedence of classes

From: [email-masked] (Joerg-Cyril Hoehle)
Date: Fri, 27 Jan 95 13:18:07 +0100

Hi,

what's wrong with the following

(defclass class1 () ())
#<STANDARD-CLASS CLASS1>
1. Break> (defclass class2 (class1) ())
#<STANDARD-CLASS CLASS2>
1. Break> (defclass class3 (class1 class2) ())

*** - DEFCLASS CLASS3: inconsistent precedence graph, cycle (#<STANDARD-CLASS CLASS2> #<STANDARD-CLASS CLASS1>)
2. Break> 

Why isn't the precedence of class3 not simply (class2 class1)?

 	Joerg Hoehle.
[email-masked]

---

From: Pascal POIZAT - DEA Info <[email-masked]>
Date: Fri, 27 Jan 1995 14:22:44 +0100

If you do

c1->()
c2->c1
c3->c1,c2
(inheritance links) then CLOS generates a cycling precedence list for c3.
Don't forget that it will add an extra link between c1->c2 thus making (c1,c2) a cycle.

                        c1
                     /\       /\
                     |        |
                    c2 <---   c3
this is what you did.
Then CLOS modifies this to obtain:
                        c1
                  /\    |    /\
                  |    \/    |
                     c2  <-- c3
and here there is a cycle between c1 and c2.
This is because you specified c1 before c2 in c3's inheritance list.
When you say that c inherits from c1 c2 c3 ... ci ci+1 ... cn
then you create implicit (for CLOS) links between c1 and c2, c2 and c3, ..., ci and ci+1,
cn-1 and cn.

Just try modifying class3 by making it like this:
(defclass class3 (class2 class1) ()) it should work.

Pascal Poizat
DEA Informatique, Nantes, France
(pre PhD year in Computer Science)
Applying Rewriting to Object Specifications using CLOS.

PS: thanks for mailing me the place where to find the last version of CLISP-HIGH.

[email-masked]

PS2: I mailed this directly to you, since if you receive hundreds of answers you
could join them and then mail them to the mailing-list.

---

From: haible (Bruno Haible)
Date: Fri, 27 Jan 95 14:37:40 +0100

Joerg Hoehle <[email-masked]> asks:

> (defclass class2 (class1) ())
> (defclass class3 (class1 class2) ())

The CLOS rules for determining the effective method of a generic function
rely on the fact that if B is a subclass of A, then the class precedence list
of A is contained in the class precedence list of B *in* *that* *order*.

In your example, the CPL of class3 would have to contain (class2 class1)
- because this is the CPL of class2 - and would have to contain
(class3 class1 class2) - because that are the direct superclasses you
specified -. Obviously you can't have both.

                    Bruno Haible
                    [email-masked]