1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Body/07_ffd.htm
2024-04-01 10:24:07 +02:00

51 lines
8.8 KiB
HTML

<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
<HTML>
<HEAD>
<TITLE>CLHS: Section 7.6.6.4</TITLE>
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
<LINK REL=TOP HREF="../Front/index.htm">
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
<LINK REL=PREV HREF="07_ffc.htm">
<LINK REL=UP HREF="07_ff.htm">
<LINK REL=NEXT HREF="07_fg.htm">
</HEAD>
<BODY>
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="07_ffc.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="07_ff.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="07_fg.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>
7.6.6.4 Built-in Method Combination Types</H2> <P>
The object system provides a set of built-in method combination types. To specify that a generic function is to use one of these method combination types, the name of the method combination type is given as the argument to the <TT>:method-combination</TT> option to <A REL=DEFINITION HREF="m_defgen.htm#defgeneric"><B>defgeneric</B></A> or to the <TT>:method-combination</TT> option to any of the other operators that specify generic function options. <P>
The names of the built-in method combination types are listed in the next figure. <P>
<PRE>
<A REL=DEFINITION HREF="a_pl.htm#PL">+</A> <A REL=DEFINITION HREF="f_append.htm#append">append</A> <A REL=DEFINITION HREF="f_max_m.htm#max">max</A> <A REL=DEFINITION HREF="f_nconc.htm#nconc">nconc</A> <A REL=DEFINITION HREF="s_progn.htm#progn">progn</A>
<A REL=DEFINITION HREF="a_and.htm#and">and</A> <A REL=DEFINITION HREF="a_list.htm#list">list</A> <A REL=DEFINITION HREF="f_max_m.htm#min">min</A> <A REL=DEFINITION HREF="a_or.htm#or">or</A> <A REL=DEFINITION HREF="07_ffb.htm#standard">standard</A>
</PRE>
<P><B>Figure 7-2. Built-in Method Combination Types</B> <P>
The semantics of the <A REL=DEFINITION HREF="07_ffb.htm#standard"><B>standard</B></A> built-in method combination type is described in <A REL=CHILD HREF="07_ffb.htm">Section 7.6.6.2 (Standard Method Combination)</A>. The other built-in method combination types are called simple built-in method combination types. <P>
The simple built-in method combination types act as though they were defined by the short form of <A REL=DEFINITION HREF="m_defi_4.htm#define-method-combination"><B>define-method-combination</B></A>. They recognize two roles for <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>methods</I></A>: <P>
<P><DL><P>
<DT>* An <A REL=DEFINITION HREF="26_glo_a.htm#around_method"><I>around method</I></A> has the keyword symbol <TT>:around</TT> as its sole <A REL=DEFINITION HREF="26_glo_q.htm#qualifier"><I>qualifier</I></A>. The meaning of <TT>:around</TT> <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>methods</I></A> is the same as in standard method combination. Use of the functions <A REL=DEFINITION HREF="f_call_n.htm#call-next-method"><B>call-next-method</B></A> and <A REL=DEFINITION HREF="f_next_m.htm#next-method-p"><B>next-method-p</B></A> is supported in <A REL=DEFINITION HREF="26_glo_a.htm#around_method"><I>around methods</I></A>. <P><DD>
<DT>* A primary method has the name of the method combination type as its sole <A REL=DEFINITION HREF="26_glo_q.htm#qualifier"><I>qualifier</I></A>. For example, the built-in method combination type <TT>and</TT> recognizes methods whose sole <A REL=DEFINITION HREF="26_glo_q.htm#qualifier"><I>qualifier</I></A> is <TT>and</TT>; these are primary methods. Use of the functions <A REL=DEFINITION HREF="f_call_n.htm#call-next-method"><B>call-next-method</B></A> and <A REL=DEFINITION HREF="f_next_m.htm#next-method-p"><B>next-method-p</B></A> is not supported in <A REL=DEFINITION HREF="26_glo_p.htm#primary_method"><I>primary methods</I></A>. <P><DD>
<P></DL><P>
The semantics of the simple built-in method combination types is as follows: <P>
<P><DL><DT>* If there are any <A REL=DEFINITION HREF="26_glo_a.htm#around_method"><I>around methods</I></A>, the most specific <A REL=DEFINITION HREF="26_glo_a.htm#around_method"><I>around method</I></A> is called. It supplies the value or values of the <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic function</I></A>. <P><DD>
<DT>* Inside the body of an <A REL=DEFINITION HREF="26_glo_a.htm#around_method"><I>around method</I></A>, the function <A REL=DEFINITION HREF="f_call_n.htm#call-next-method"><B>call-next-method</B></A> can be used to call the <A REL=DEFINITION HREF="26_glo_n.htm#next_method"><I>next method</I></A>. The <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic function</I></A> <A REL=DEFINITION HREF="f_no_nex.htm#no-next-method"><B>no-next-method</B></A> is invoked if <A REL=DEFINITION HREF="f_call_n.htm#call-next-method"><B>call-next-method</B></A> is used and there is no applicable method to call. The <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>function</I></A> <A REL=DEFINITION HREF="f_next_m.htm#next-method-p"><B>next-method-p</B></A> may be used to determine whether a <A REL=DEFINITION HREF="26_glo_n.htm#next_method"><I>next method</I></A> exists. When the <A REL=DEFINITION HREF="26_glo_n.htm#next_method"><I>next method</I></A> returns, the <A REL=DEFINITION HREF="26_glo_a.htm#around_method"><I>around method</I></A> can execute more code, perhaps based on the returned value or values. <P><DD>
<DT>* If an <A REL=DEFINITION HREF="26_glo_a.htm#around_method"><I>around method</I></A> invokes <A REL=DEFINITION HREF="f_call_n.htm#call-next-method"><B>call-next-method</B></A>, the next most specific <A REL=DEFINITION HREF="26_glo_a.htm#around_method"><I>around method</I></A> is called, if one is applicable. If there are no <A REL=DEFINITION HREF="26_glo_a.htm#around_method"><I>around methods</I></A> or if <A REL=DEFINITION HREF="f_call_n.htm#call-next-method"><B>call-next-method</B></A> is called by the least specific <A REL=DEFINITION HREF="26_glo_a.htm#around_method"><I>around method</I></A>, a Lisp form derived from the name of the built-in method combination type and from the list of applicable primary methods is evaluated to produce the value of the generic function. Suppose the name of the method combination type is <I>operator</I> and the call to the generic function is of the form <P><DD>
<P> (<I>generic-function</I> a1...an)<P> <P>
<DT> Let M1,...,Mk be the applicable primary methods in order; then the derived Lisp form is <P><DD>
<P> (<I>operator</I> &lt;M1 a1...an&gt;...&lt;Mk a1...an&gt;)<P> <P>
<DT> If the expression &lt;Mi a1...an&gt; is evaluated, the method Mi will be applied to the arguments a1...an. For example, if <I>operator</I> is <TT>or</TT>, the expression &lt;Mi a1...an&gt; is evaluated only if &lt;Mj a1...an&gt;, 1&lt;=j&lt;i, returned <TT>nil</TT>. <P><DD>
<DT> The default order for the primary methods is <TT>:most-specific-first</TT>. However, the order can be reversed by supplying <TT>:most-specific-last</TT> as the second argument to the <TT>:method-combination</TT> option. <P><DD></DL><P>
The simple built-in method combination types require exactly one <A REL=DEFINITION HREF="26_glo_q.htm#qualifier"><I>qualifier</I></A> per method. An error is signaled if there are applicable methods with no <A REL=DEFINITION HREF="26_glo_q.htm#qualifier"><I>qualifiers</I></A> or with <A REL=DEFINITION HREF="26_glo_q.htm#qualifier"><I>qualifiers</I></A> that are not supported by the method combination type. An error is signaled if there are applicable <A REL=DEFINITION HREF="26_glo_a.htm#around_method"><I>around methods</I></A> and no applicable primary methods. <P>
<HR>
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
</BODY>
</HTML>