From: Robert Posey
Subject: Precedence Question?
Date: 
Message-ID: <38A35B6F.FDF1AED3@raytheon.com>
Dear Gentle Sirs,

I have a disagreement on legal class precedence.



Is this legal?


(defclass C0 () (s1 s2 s3))

(defclass C2 (C0) ())

(defclass c1 () (s4))

(defclass c3 (c0 c1 c2) ())


Which would give this Precedence Graph(I think)


  C0--->----C2-->\
   |____>_______/ C3

  C1--------->--/


I believe this is illegal, but is there a nice formal way to
state why.  It looks to me like the link from C0 to C3 will cause
problems, since it shouldn't do anything anyway.  It
is accept in Harlequin Interpreter, but in class browser it says it
can't compute precedence.  In Cormen Lisp it gives an error when
it is complied.  What is the formal term for the problem caused
by the lack of intervening class on the C0 to c3 connection.

Muddy

From: Fred Gilham
Subject: Re: Precedence Question?
Date: 
Message-ID: <u7bt5ndbmu.fsf@snapdragon.csl.sri.com>
Robert Posey writes:
>I believe this is illegal, but is there a nice formal way to
>state why.  It looks to me like the link from C0 to C3 will cause
>problems, since it shouldn't do anything anyway. 

Here's what I get when I type this in to CMUCL, which uses PCL.  It
seems revealing:

*  (defclass C0 () (s1 s2 s3))

#<STANDARD-CLASS C0 {482F7615}>
* (defclass C2 (C0) ())

#<STANDARD-CLASS C2 {48302B65}>
* (defclass c1 () (s4))

#<STANDARD-CLASS C1 {4830D51D}>
* (defclass c3 (c0 c1 c2) ())


Error in function PCL::CPL-ERROR:
   While computing the class precedence list of the class named C3.
It is not possible to compute the class precedence list because
there is a circularity in the local precedence relations.
This arises because:
  the class named C0 appears in the supers of the class named C2
  the class named C1 follows the class named C0 in the supers of the class named C3
  the class named C2 follows the class named C1 in the supers of the class named C3.


{t

So maybe the phrase you're looking for is ``circularity in the local
precedence relations.''

-- 
Fred Gilham                                      ······@csl.sri.com
I have over the years been viewed as a man of the left and a man of
the right, and the truth is that I've never put much stake in such
labels. But this I have learned: the left patrols its borders and
checks membership credentials ever so much more scrupulously, even
ruthlessly, than does the right.            -- Richard John Neuhaus
From: Christopher J. Vogt
Subject: Re: Precedence Question?
Date: 
Message-ID: <38A44357.234AFC36@computer.org>
Robert Posey wrote:
> 
> Dear Gentle Sirs,
> 
> I have a disagreement on legal class precedence.
> 
> Is this legal?
> 
> (defclass C0 () (s1 s2 s3))
> 
> (defclass C2 (C0) ())
> 
> (defclass c1 () (s4))
> 
> (defclass c3 (c0 c1 c2) ())

I was very suprised that this didn't compile, as I was pretty sure it was
legal, so I checked my current Lisp implementations.  This works just fine w/ 
Harlequin Lispworks 4.1 on Windows NT and with ACL 5.0.1 on Windows also.
From: Gareth McCaughan
Subject: Re: Precedence Question?
Date: 
Message-ID: <86d7q3jj5n.fsf@g.local>
Robert Posey wrote:

> Is this legal?
> 
> 
> (defclass C0 () (s1 s2 s3))
> 
> (defclass C2 (C0) ())
> 
> (defclass c1 () (s4))
> 
> (defclass c3 (c0 c1 c2) ())

Here's what the HyperSpec says. (Ruthlessly pruned.)

  - The defclass form provides a total ordering on the
    class and its direct superclasses, called the local
    precedence order.

    (The LPO for your class C3 is C3 < C0 < C1 < C2.)

  - The class precedence list is a total ordering on
    C and all its superclasses that is consistent with
    the local precedence orders for all those classes.

    (The LPOs are C2 < C0 and C3 < C0 < C1 < C2. They
    are not consistent.)

  - If the union of all the local precedence orders is
    inconsistent, an error is signalled.

Hence, the class definitions you gave are not legal.

-- 
Gareth McCaughan  ················@pobox.com
sig under construction
From: Marco Antoniotti
Subject: Re: Precedence Question?
Date: 
Message-ID: <lwsnyylgx9.fsf@parades.rm.cnr.it>
Gareth McCaughan <················@pobox.com> writes:

> Robert Posey wrote:
> 
> > Is this legal?
> > 
> > 
> > (defclass C0 () (s1 s2 s3))
> > 
> > (defclass C2 (C0) ())
> > 
> > (defclass c1 () (s4))
> > 
> > (defclass c3 (c0 c1 c2) ())
> 
> Here's what the HyperSpec says. (Ruthlessly pruned.)
> 
>   - The defclass form provides a total ordering on the
>     class and its direct superclasses, called the local
>     precedence order.
> 
>     (The LPO for your class C3 is C3 < C0 < C1 < C2.)
> 
>   - The class precedence list is a total ordering on
>     C and all its superclasses that is consistent with
>     the local precedence orders for all those classes.
> 
>     (The LPOs are C2 < C0 and C3 < C0 < C1 < C2. They
>     are not consistent.)
> 
>   - If the union of all the local precedence orders is
>     inconsistent, an error is signalled.
> 
> Hence, the class definitions you gave are not legal.

On a different note, once you understand this notion of topologically
sorted class precedence lists, you understand why this makes way more
sense than 

	class zut : public virtual zot, public virtual gnao

etc. etc.

You also understand why Java hase single class inheritance an multiple
interface implementation.

Finally you see why the CL way is the more versatile.

Cheers


-- 
Marco Antoniotti ===========================================
PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY
tel. +39 - 06 68 10 03 17, fax. +39 - 06 68 80 79 26
http://www.parades.rm.cnr.it/~marcoxa