| 1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| 2 |
<html> |
| 3 |
<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ --> |
| 4 |
<head> |
| 5 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 6 |
<title>Examples of Keyword Arguments in Generic Functions and Methods (ANSI and GNU Common Lisp Document)</title> |
| 7 |
|
| 8 |
<meta name="description" content="Examples of Keyword Arguments in Generic Functions and Methods (ANSI and GNU Common Lisp Document)"> |
| 9 |
<meta name="keywords" content="Examples of Keyword Arguments in Generic Functions and Methods (ANSI and GNU Common Lisp Document)"> |
| 10 |
<meta name="resource-type" content="document"> |
| 11 |
<meta name="distribution" content="global"> |
| 12 |
<meta name="Generator" content="makeinfo"> |
| 13 |
<link href="index.html" rel="start" title="Top"> |
| 14 |
<link href="Keyword-Arguments-in-Generic-Functions-and-Methods.html" rel="up" title="Keyword Arguments in Generic Functions and Methods"> |
| 15 |
<link href="Method-Selection-and-Combination.html" rel="next" title="Method Selection and Combination"> |
| 16 |
<link href="Keyword-Arguments-in-Generic-Functions-and-Methods.html" rel="prev" title="Keyword Arguments in Generic Functions and Methods"> |
| 17 |
<style type="text/css"> |
| 18 |
<!-- |
| 19 |
a.summary-letter {text-decoration: none} |
| 20 |
blockquote.indentedblock {margin-right: 0em} |
| 21 |
div.display {margin-left: 3.2em} |
| 22 |
div.example {margin-left: 3.2em} |
| 23 |
div.lisp {margin-left: 3.2em} |
| 24 |
kbd {font-style: oblique} |
| 25 |
pre.display {font-family: inherit} |
| 26 |
pre.format {font-family: inherit} |
| 27 |
pre.menu-comment {font-family: serif} |
| 28 |
pre.menu-preformatted {font-family: serif} |
| 29 |
span.nolinebreak {white-space: nowrap} |
| 30 |
span.roman {font-family: initial; font-weight: normal} |
| 31 |
span.sansserif {font-family: sans-serif; font-weight: normal} |
| 32 |
ul.no-bullet {list-style: none} |
| 33 |
--> |
| 34 |
</style> |
| 35 |
|
| 36 |
|
| 37 |
</head> |
| 38 |
|
| 39 |
<body lang="en"> |
| 40 |
<span id="Examples-of-Keyword-Arguments-in-Generic-Functions-and-Methods"></span><div class="header"> |
| 41 |
<p> |
| 42 |
Previous: <a href="Keyword-Arguments-in-Generic-Functions-and-Methods.html" accesskey="p" rel="prev">Keyword Arguments in Generic Functions and Methods</a>, Up: <a href="Keyword-Arguments-in-Generic-Functions-and-Methods.html" accesskey="u" rel="up">Keyword Arguments in Generic Functions and Methods</a> </p> |
| 43 |
</div> |
| 44 |
<hr> |
| 45 |
<span id="Examples-of-Keyword-Arguments-in-Generic-Functions-and-Methods-1"></span><h4 class="subsubsection">7.6.5.1 Examples of Keyword Arguments in Generic Functions and Methods</h4> |
| 46 |
|
| 47 |
<p>For example, suppose there are two methods defined for <tt>width</tt> |
| 48 |
as follows: |
| 49 |
</p> |
| 50 |
<div class="example"> |
| 51 |
<pre class="example"> (defmethod width ((c character-class) &key font) ...) |
| 52 |
|
| 53 |
(defmethod width ((p picture-class) &key pixel-size) ...) |
| 54 |
</pre></div> |
| 55 |
|
| 56 |
<p>Assume that there are no other methods and no generic |
| 57 |
function definition for <tt>width</tt>. The evaluation of the |
| 58 |
following form should signal an error because |
| 59 |
the keyword argument <tt>:pixel-size</tt> is not accepted by the applicable method. |
| 60 |
</p> |
| 61 |
<div class="example"> |
| 62 |
<pre class="example"> (width (make-instance `character-class :char #\Q) |
| 63 |
:font 'baskerville :pixel-size 10) |
| 64 |
</pre></div> |
| 65 |
|
| 66 |
<p>The evaluation of the following form should signal an error. |
| 67 |
</p> |
| 68 |
<div class="example"> |
| 69 |
<pre class="example"> (width (make-instance `picture-class :glyph (glyph #\Q)) |
| 70 |
:font 'baskerville :pixel-size 10) |
| 71 |
</pre></div> |
| 72 |
|
| 73 |
<p>The evaluation of the following form will not signal an error |
| 74 |
if the class named <tt>character-picture-class</tt> is a subclass of |
| 75 |
both <tt>picture-class</tt> and <tt>character-class</tt>. |
| 76 |
</p> |
| 77 |
<div class="example"> |
| 78 |
<pre class="example"> (width (make-instance `character-picture-class :char #\Q) |
| 79 |
:font 'baskerville :pixel-size 10) |
| 80 |
</pre></div> |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
</body> |
| 86 |
</html> |