DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(goops.info.gz) Class hierarchy and inheritance of slots

Info Catalog (goops.info.gz) Inheritance (goops.info.gz) Inheritance (goops.info.gz) Instance creation and slot access
 
 Class hierarchy and inheritance of slots
 ----------------------------------------
 
 Inheritance is specified upon class definition. As said in the
 introduction, GOOPS supports multiple inheritance.  Here are some class
 definitions:
 
      (define-class A () a)
      (define-class B () b)
      (define-class C () c)
      (define-class D (A B) d a)
      (define-class E (A C) e c)
      (define-class F (D E) f)
 
 `A', `B', `C' have a null list of super classes. In this case, the
 system will replace it by the list which only contains `<object>', the
 root of all the classes defined by `define-class'. `D', `E', `F' use
 multiple inheritance: each class inherits from two previously defined
 classes.  Those class definitions define a hierarchy which is shown in
 Figure 1.  In this figure, the class `<top>' is also shown; this class
 is the super class of all Scheme objects. In particular, `<top>' is the
 super class of all standard Scheme types.
 
      [image src=hierarchy.png text="          <top>
                / \\\\\\_____________________
               /   \\\\___________          \\
              /     \\           \\          \\
          <object>  <pair>  <procedure>  <number>
          /  |  \\                           |
         /   |   \\                          |
        A    B    C                      <complex>
        |\\__/__   |                         |
         \\ /   \\ /                          |
          D     E                         <real>
           \\   /                            |
             F                              |
                                         <integer>
      "]
                            _Fig 1: A class hierarchy_
 
 The set of slots of a given class is calculated by taking the union of
 the slots of all its super class. For instance, each instance of the
 class D, defined before will have three slots (`a', `b' and `d'). The
 slots of a class can be obtained by the `class-slots' primitive.  For
 instance,
 
      (class-slots A) => ((a))
      (class-slots E) => ((a) (e) (c))
      (class-slots F) => ((e) (c) (b) (d) (a) (f))
 
 _Note: _ The order of slots is not significant.
 
Info Catalog (goops.info.gz) Inheritance (goops.info.gz) Inheritance (goops.info.gz) Instance creation and slot access
automatically generated byinfo2html