ToC DocOverview CGDoc RelNotes Index PermutedIndex
Allegro CL
Home Previous Up Next Table of Contents Index
  ANSI Common Lisp   7 Objects   7.6 Generic Functions and Methods   7.6.5 Keyword Arguments in Generic Functions and Methods

7.6.5.1 Examples of Keyword Arguments in Generic Functions and Methods

For example, suppose there are two methods defined for width as follows:

 (defmethod width ((c character-class) &key font) ...)
 
 (defmethod width ((p picture-class) &key pixel-size) ...)

Assume that there are no other methods and no generic function definition for width. The evaluation of the following form should signal an error because the keyword argument :pixel-size is not accepted by the applicable method.

 (width (make-instance `character-class :char #\Q) 
        :font 'baskerville :pixel-size 10)

The evaluation of the following form should signal an error.

 (width (make-instance `picture-class :glyph (glyph #\Q)) 
        :font 'baskerville :pixel-size 10)

The evaluation of the following form will not signal an error if the class named character-picture-class is a subclass of both picture-class and character-class.

 (width (make-instance `character-picture-class :char #\Q)
        :font 'baskerville :pixel-size 10)


Home Previous Up Next Table of Contents Index
© Franz Inc. 1998-2012 - File last updated 02-24-2012