[Next] [Previous] [Up] [Top] [Contents] [Index]

Method combination

The primary method and the class precedence list

It is important to know in what order to look up methods. When a class has many superclasses, behavior is determined by the ordered list of its superclasses--its class precedence list. The class precedence list is basic to method combination.

The order in which the superclasses are listed determines the order in which their primary methods are consulted. If the instance has a method, that method is used. If the class has a method, that is used. Otherwise the look-up consults the first (leftmost) superclass in the class precedence list, looking up the class's methods and those of the class's superclasses, leftmost superclass first. If there is no appropriate method anywhere in the first superclass or its superclasses, the look-up proceeds to the second superclass, and so on. The first applicable primary method that is found is used.

However, when elements of the class precedence list have superclasses in common, CLOS examines, in this order:

  1. all of the elements of the first superclass except the class in common
  2. all of the elements of the second superclass except the class in common
  3. the class in common (followed by its superclasses)


Gettmg Started with MCL - 19 OCT 1996
[Next] [Previous] [Up] [Top] [Contents] [Index]

Generated with Harlequin WebMaker