Note: This is taken from the Chicken Wiki, where a more recent version could be available.

c3

Description

Implements C3 class linearization for TinyCLOS. For more information, see: http://www.webcom.com/~haahr/dylan/linearization-oopsla96.html and http://www.python.org/2.3/mro.html

Author

Alex Shinn

Requirements

The tinyclos egg.

Download

c3.egg

Documentation

To load:

 (use c3)

When loaded, all subsequent class definitions obey C3 linearization. It's not possible to switch back to the default, once it is active.

Examples

<example> <init>(use c3)</init> <expr>;; by Michele Simionato

(define O <object>)

; first example

(define-class F (O) ()) (define-class E (O) ()) (define-class D (O) ()) (define-class C (D F) ()) (define-class B (D E) ()) (define-class A (B C) ())

with CLOS

(class-cpl A) (A B C D F E object top)

with C3

(class-cpl A) (A B C D E F object top) ; E ↔ F</expr> </example>

<example> <init>(use c3)</init> <expr>;; second example (define-class F (O) ()) (define-class E (O) ()) (define-class D (O) ()) (define-class C (D F) ()) (define-class B (E D) ()) (define-class A (B C) ())

with CLOS

(class-cpl A) (A B E C D F object top)

with C3

(class-cpl A) (A B E C D F object top) ; identical</expr> </example>

<example> <init>(use c3)</init> <expr>;; Pedroni's example (define-class A(O) ()) (define-class B(O) ()) (define-class C(O) ()) (define-class D(O) ()) (define-class E(O) ()) (define-class K1(A B C) ()) (define-class K2(D B E) ()) (define-class K3(D A) ()) (define-class Z(K1 K2 K3) ())

with CLOS

(class-cpl Z) (Z K1 K2 K3 D A B E C object top)

with C3

(class-cpl Z) (Z K1 K2 K3 D A B C E object top) ; E ↔ C</expr> </example>

Changelog

License

 Copyright (c) 2004, Alex Shinn
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
 conditions are met:
 
   Redistributions of source code must retain the above copyright notice, this list of conditions and the following
     disclaimer. 
   Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
     disclaimer in the documentation and/or other materials provided with the distribution. 
   Neither the name of the author nor the names of its contributors may be used to endorse or promote
     products derived from this software without specific prior written permission. 
 
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 POSSIBILITY OF SUCH DAMAGE.