User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cl:functions:find-method [2019/09/14 05:00]
cl:functions:find-method [2019/11/14 00:00] (current)
Line 1: Line 1:
 +====== Standard Generic Function FIND-METHOD ======
 +
 +====Syntax====
 +  * **Newline find-method** //​generic-function method-qualifiers specializers ''&​optional''​ errorp// → //method//
 +
 +====Method Signatures====
 +  * **find-method** (//​generic-function//​ **[[CL:​Types:​standard-generic-function]]**) //​method-qualifiers specializers ''&​optional''​ errorp//
 +
 +====Arguments and Values====
 +  * //​generic-function//​ - a //​[[CL:​Glossary:​generic function]]//​.
 +  * //​method-qualifiers//​ - a //​[[CL:​Glossary:​list]]//​.
 +  * //​specializers//​ - a //​[[CL:​Glossary:​list]]//​.
 +  * //errorp// - a //​[[CL:​Glossary:​generalized boolean]]//​. The default is //​[[CL:​Glossary:​true]]//​.
 +  * //method// - a //​[[CL:​Glossary:​method]]//​ //​[[CL:​Glossary:​object]]//,​ or **[[CL:​Constant Variables:​nil]]**.
 +
 +====Description====
 +The //​[[CL:​Glossary:​generic function]]//​ **find-method** takes a //​[[CL:​Glossary:​generic function]]//​ and returns the //​[[CL:​Glossary:​method]]//​ //​[[CL:​Glossary:​object]]//​ that agrees on //​[[CL:​Glossary:​qualifier|qualifiers]]//​ and //​[[CL:​Glossary:​parameter specializer|parameter specializers]]//​ with the //​method-qualifiers//​ and //​specializers//​ arguments of **find-method**. //​Method-qualifiers//​ contains the method //​[[CL:​Glossary:​qualifier|qualifiers]]//​ for the //​[[CL:​Glossary:​method]]//​. The order of the method //​[[CL:​Glossary:​qualifier|qualifiers]]//​ is significant. For a definition of agreement in this context, see section {\secref\SpecializerQualifierAgreement}.
 +
 +The //​specializers//​ argument contains the parameter specializers for the //​[[CL:​Glossary:​method]]//​. It must correspond in length to the number of required arguments of the //​[[CL:​Glossary:​generic function]]//,​ or an error is signaled. This means that to obtain the default //​[[CL:​Glossary:​method]]//​ on a given //​generic-function//,​ a //​[[CL:​Glossary:​list]]//​ whose elements are the //​[[CL:​Glossary:​class]]//​ **[[CL:​Types:​t]]** must be given.
 +
 +If there is no such //​[[CL:​Glossary:​method]]//​ and //errorp// is //​[[CL:​Glossary:​true]]//,​ **find-method** signals an error. If there is no such //​[[CL:​Glossary:​method]]//​ and //errorp// is //​[[CL:​Glossary:​false]]//,​ **find-method** returns **[[CL:​Constant Variables:​nil]]**.
 +
 +====Examples====
 +<​blockquote>​ (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 </​blockquote>​
 +
 +====Affected By====
 +**[[CL:​Functions:​add-method]]**,​ **[[CL:​Macros:​defclass]]**,​ **[[CL:​Macros:​defgeneric]]**,​ **[[CL:​Macros:​defmethod]]**
 +
 +====Exceptional Situations====
 +If the //​specializers//​ argument does not correspond in length to the number of required arguments of the //​generic-function//,​ an an error of type **[[CL:​Types:​error]]** is signaled.
 +
 +If there is no such //​[[CL:​Glossary:​method]]//​ and //errorp// is //​[[CL:​Glossary:​true]]//,​ **find-method** signals an error of type **[[CL:​Types:​error]]**.
 +
 +====See Also====
 +  * {\secref\SpecializerQualifierAgreement}
 +
 +====Notes====
 +None.
 +