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

Definitions

Generic functions and methods

Behavior is expressed through generic functions, Lisp functions whose behavior depends on the classes or identities of the arguments supplied.

  • A generic function has methods for a number of classes. That is, the generic function has a number of ways to perform a procedure, each way designed to be used for a specific class. For example, the generic function view-draw-contents has one method for simple views, one for views, one for windows, and so on. That is, it knows how to draw the contents of a simple view, the contents of a view, and so on.
  • These methods are related but usually not identical (for instance, the view-draw-contents method for simple-view doesn't need to handle subviews, but the one for view does).
  • When you want to perform an operation on some objects, you apply a generic function to an instance. By determining which methods of the generic function are associated with the instance's class, the generic function knows which of its methods to apply to the instance.
  • Methods are applied to instances through method combination. A generic function determines one primary method suitable for an instance--one basic procedure that is the most appropriate to the instance. It may also call other methods through call-next-method. One or more auxiliary methods may be run before or after the primary method. The entire group of methods applicable to the instance is called the effective method.
  • Methods have arguments, just as functions do.
  • Methods of the same generic function must always have the same number of required and optional arguments; that is, they must have congruent lambda lists.
  • The required arguments of a method are specialized; that is, each argument is associated with a class or an instance. The specializers of a method determine whether the method is appropriate for a given set of arguments.


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

    Generated with Harlequin WebMaker