Common Lisp the Language, 2nd Edition


next up previous contents index
Next: Declarative Method Combination Up: Method Selection and Previous: Determining the Effective

28.1.7.2. Standard Method Combination

change_begin
Standard method combination is supported by the class standard-generic-function. It is used if no other type of method combination is specified or if the built-in method combination type standard is specified.

Primary methods define the main action of the effective method, while auxiliary methods modify that action in one of three ways. A primary method has no method qualifiers.

An auxiliary method is a method whose method qualifier is :before, :after, or :around. Standard method combination allows no more than one qualifier per method; if a method definition specifies more than one qualifier per method, an error is signaled.

The semantics of standard method combination are as follows:

In standard method combination, if there is an applicable method but no applicable primary method, an error is signaled.

The :before methods are run in most-specific-first order and the :after methods are run in least-specific-first order. The design rationale for this difference can be illustrated with an example. Suppose class modifies the behavior of its superclass, , by adding :before and :after methods. Whether the behavior of the class is defined directly by methods on or is inherited from its superclasses does not affect the relative order of invocation of methods on instances of the class . Class 's :before method runs before all of class 's methods. Class 's :after method runs after all of class 's methods.

By contrast, all :around methods run before any other methods run. Thus a less specific :around method runs before a more specific primary method.

If only primary methods are used and if call-next-method is not used, only the most specific method is invoked; that is, more specific methods shadow more general ones.
change_end



next up previous contents index
Next: Declarative Method Combination Up: Method Selection and Previous: Determining the Effective


AI.Repository@cs.cmu.edu