74 lines
7.3 KiB
HTML
74 lines
7.3 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: Standard Generic Function FIND-METHOD</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="m_defi_4.htm">
|
|
<LINK REL=UP HREF="c_object.htm">
|
|
<LINK REL=NEXT HREF="f_add_me.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="m_defi_4.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="c_object.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="f_add_me.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
<A NAME="find-method"><I>Standard Generic Function</I> <B>FIND-METHOD</B></A> <P>
|
|
<P><B>Syntax:</B><P>
|
|
<P>
|
|
|
|
<B>find-method</B> <I>generic-function method-qualifiers specializers <TT>&optional</TT> errorp</I><P> => <I>method</I><P>
|
|
<P>
|
|
<P><B>Method Signatures:</B><P>
|
|
<P>
|
|
|
|
<B>find-method</B> <I>(<I>generic-function</I><B> <A REL=DEFINITION HREF="t_std_ge.htm#standard-generic-function">standard-generic-function</A></B>) method-qualifiers specializers <TT>&optional</TT> errorp</I><P>
|
|
<P>
|
|
<P><B>Arguments and Values:</B><P>
|
|
<P>
|
|
<I>generic-function</I>---a <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic function</I></A>. <P>
|
|
<I>method-qualifiers</I>---a <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A>. <P>
|
|
<I>specializers</I>---a <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A>. <P>
|
|
<I>errorp</I>---a <A REL=DEFINITION HREF="26_glo_g.htm#generalized_boolean"><I>generalized boolean</I></A>. The default is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>. <P>
|
|
<I>method</I>---a <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>method</I></A> <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A>, or <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>. <P>
|
|
<P><B>Description:</B><P>
|
|
<P>
|
|
The <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic function</I></A> <A REL=DEFINITION HREF="#find-method"><B>find-method</B></A> takes a <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic function</I></A> and returns the <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>method</I></A> <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> that agrees on <A REL=DEFINITION HREF="26_glo_q.htm#qualifier"><I>qualifiers</I></A> and <A REL=DEFINITION HREF="26_glo_p.htm#parameter_specializer"><I>parameter specializers</I></A> with the <I>method-qualifiers</I> and <I>specializers</I> arguments of <A REL=DEFINITION HREF="#find-method"><B>find-method</B></A>. <I>Method-qualifiers</I> contains the method <A REL=DEFINITION HREF="26_glo_q.htm#qualifier"><I>qualifiers</I></A> for the <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>method</I></A>. The order of the method <A REL=DEFINITION HREF="26_glo_q.htm#qualifier"><I>qualifiers</I></A> is significant. For a definition of agreement in this context, see <A REL=CHILD HREF="07_fc.htm">Section 7.6.3 (Agreement on Parameter Specializers and Qualifiers)</A>. <P>
|
|
The <I>specializers</I> argument contains the parameter specializers for the <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>method</I></A>. It must correspond in length to the number of required arguments of the <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic function</I></A>, or an error is signaled. This means that to obtain the default <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>method</I></A> on a given <I>generic-function</I>, a <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A> whose elements are the <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> <A REL=DEFINITION HREF="t_t.htm#t"><B>t</B></A> must be given. <P>
|
|
If there is no such <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>method</I></A> and <I>errorp</I> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>, <A REL=DEFINITION HREF="#find-method"><B>find-method</B></A> signals an error. If there is no such <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>method</I></A> and <I>errorp</I> is <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>, <A REL=DEFINITION HREF="#find-method"><B>find-method</B></A> returns <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>. <P>
|
|
<P><B>Examples:</B><P>
|
|
<P>
|
|
<PRE>
|
|
(defmethod some-operation ((a integer) (b float)) (list a b))
|
|
=> #<STANDARD-METHOD SOME-OPERATION (INTEGER FLOAT) 26723357>
|
|
(find-method #'some-operation '() (mapcar #'find-class '(integer float)))
|
|
=> #<STANDARD-METHOD SOME-OPERATION (INTEGER FLOAT) 26723357>
|
|
(find-method #'some-operation '() (mapcar #'find-class '(integer integer)))
|
|
>> Error: No matching method
|
|
(find-method #'some-operation '() (mapcar #'find-class '(integer integer)) nil)
|
|
=> NIL
|
|
</PRE>
|
|
</TT> <P>
|
|
<P><B>Affected By:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="f_add_me.htm#add-method"><B>add-method</B></A>, <A REL=DEFINITION HREF="m_defcla.htm#defclass"><B>defclass</B></A>, <A REL=DEFINITION HREF="m_defgen.htm#defgeneric"><B>defgeneric</B></A>, <A REL=DEFINITION HREF="m_defmet.htm#defmethod"><B>defmethod</B></A> <P>
|
|
<P><B>Exceptional Situations:</B><P>
|
|
<P>
|
|
If the <I>specializers</I> argument does not correspond in length to the number of required arguments of the <I>generic-function</I>, an an error of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="e_error.htm#error"><B>error</B></A> is signaled. <P>
|
|
If there is no such <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>method</I></A> and <I>errorp</I> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>, <A REL=DEFINITION HREF="#find-method"><B>find-method</B></A> signals an error of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="e_error.htm#error"><B>error</B></A>. <P>
|
|
<P><B>See Also:</B><P>
|
|
<P>
|
|
<A REL=CHILD HREF="07_fc.htm">Section 7.6.3 (Agreement on Parameter Specializers and Qualifiers)</A> <P>
|
|
<P><B>Notes:</B> None.
|
|
<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>
|