175 lines
No EOL
80 KiB
HTML
175 lines
No EOL
80 KiB
HTML
<!doctype html>
|
||
<html lang="en" dir="ltr" class="docs-wrapper plugin-docs plugin-id-default docs-version-current docs-doc-page docs-doc-id-chap-7/h-g-generic-functions-and-methods" data-has-hydrated="false">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="generator" content="Docusaurus v3.0.1">
|
||
<title data-rh="true">7.6 Generic Functions and Methods | Common Lisp (New) Language Reference</title><meta data-rh="true" name="viewport" content="width=device-width,initial-scale=1"><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:image" content="https://lisp-docs.github.io/cl-language-reference/img/1024px-Lisp_logo.svg.png"><meta data-rh="true" name="twitter:image" content="https://lisp-docs.github.io/cl-language-reference/img/1024px-Lisp_logo.svg.png"><meta data-rh="true" property="og:url" content="https://lisp-docs.github.io/cl-language-reference/chap-7/h-g-generic-functions-and-methods"><meta data-rh="true" property="og:locale" content="en"><meta data-rh="true" name="docusaurus_locale" content="en"><meta data-rh="true" name="docsearch:language" content="en"><meta data-rh="true" name="google-site-verification" content="Vzaw013_bfdKeUVG89Ch3W1zC9_vH9ID2dPB9Dz0vr0"><meta data-rh="true" name="docusaurus_version" content="current"><meta data-rh="true" name="docusaurus_tag" content="docs-default-current"><meta data-rh="true" name="docsearch:version" content="current"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-current"><meta data-rh="true" property="og:title" content="7.6 Generic Functions and Methods | Common Lisp (New) Language Reference"><meta data-rh="true" name="description" content="7.6.1 Introduction to Generic Functions"><meta data-rh="true" property="og:description" content="7.6.1 Introduction to Generic Functions"><link data-rh="true" rel="icon" href="../img/favicon.ico"><link data-rh="true" rel="canonical" href="h-g-generic-functions-and-methods.html"><link data-rh="true" rel="alternate" href="h-g-generic-functions-and-methods.html" hreflang="en"><link data-rh="true" rel="alternate" href="h-g-generic-functions-and-methods.html" hreflang="x-default"><link data-rh="true" rel="preconnect" href="https://C1F2Q5VM6X-dsn.algolia.net" crossorigin="anonymous"><link rel="preconnect" href="https://www.google-analytics.com">
|
||
<link rel="preconnect" href="https://www.googletagmanager.com">
|
||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-8TJCE4NSF8"></script>
|
||
<script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","G-8TJCE4NSF8",{})</script>
|
||
|
||
|
||
<link rel="search" type="application/opensearchdescription+xml" title="Common Lisp (New) Language Reference" href="../opensearch.xml"><link rel="stylesheet" href="../assets/css/styles.f13b59fe.css">
|
||
<script src="../assets/js/runtime~main.02699c25.js" defer="defer"></script>
|
||
<script src="../assets/js/main.4f0a7a76.js" defer="defer"></script>
|
||
</head>
|
||
<body class="navigation-with-keyboard">
|
||
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){try{return new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}}()||function(){try{return localStorage.getItem("theme")}catch(t){}}();t(null!==e?e:"light")}(),function(){try{const c=new URLSearchParams(window.location.search).entries();for(var[t,e]of c)if(t.startsWith("docusaurus-data-")){var a=t.replace("docusaurus-data-","data-");document.documentElement.setAttribute(a,e)}}catch(t){}}()</script><div id="__docusaurus"><div role="region" aria-label="Skip to main content"><a class="skipToContent_fXgn" href="h-g-generic-functions-and-methods.html#__docusaurus_skipToContent_fallback">Skip to main content</a></div><nav aria-label="Main" class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Toggle navigation bar" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a href="../../index.html" target="_blank" rel="noopener noreferrer" class="navbar__brand"><div class="navbar__logo"><img src="../img/logo.svg" alt="Lisp Logo" class="themedComponent_mlkZ themedComponent--light_NVdE"><img src="../img/logo.svg" alt="Lisp Logo" class="themedComponent_mlkZ themedComponent--dark_xIcU"></div><b class="navbar__title text--truncate">Common Lisp Docs</b></a><a href="../../docs/tutorial/index.html" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">Tutorial</a><a href="../index.html" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">Technical Reference</a><a href="../../docs/whylisp.html" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">Why Lisp?</a><a href="../../docs/howto.html" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">Guides</a></div><div class="navbar__items navbar__items--right"><a href="../../docs/contribute.html" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">Contribute!</a><a href="../../docs/help.html" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">Getting Help</a><a href="../../docs/about.html" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">About</a><a href="../../blog.html" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">Blog</a><a href="https://github.com/lisp-docs" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">GitHub<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a><div class="toggle_vylO colorModeToggle_DEke"><button class="clean-btn toggleButton_gllP toggleButtonDisabled_aARS" type="button" disabled="" title="Switch between dark and light mode (currently light mode)" aria-label="Switch between dark and light mode (currently light mode)" aria-live="polite"><svg viewBox="0 0 24 24" width="24" height="24" class="lightToggleIcon_pyhR"><path fill="currentColor" d="M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"></path></svg><svg viewBox="0 0 24 24" width="24" height="24" class="darkToggleIcon_wfgR"><path fill="currentColor" d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"></path></svg></button></div><div class="navbarSearchContainer_Bca1"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"></span></button></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div id="__docusaurus_skipToContent_fallback" class="main-wrapper mainWrapper_z2l0"><div class="docsWrapper_hBAB"><button aria-label="Scroll back to top" class="clean-btn theme-back-to-top-button backToTopButton_sjWU" type="button"></button><div class="docRoot_UBD9"><aside class="theme-doc-sidebar-container docSidebarContainer_YfHR"><div class="sidebarViewport_aRkj"><div class="sidebar_njMd"><nav aria-label="Docs sidebar" class="menu thin-scrollbar menu_SIkG"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="../index.html">Introduction</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-0/intro.html">Contents and Figures</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-1/b-b-scope-purpose-and-history.html">1. Introduction</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-2/c-b-character-syntax.html">2. Syntax</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-3/d-b-evaluation.html">3. Evaluation and Compilation</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-4/e-b-introduction.html">4. Types and Classes</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-5/f-b-generalized-reference.html">5. Data and Control Flow</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-6/g-b-the-loop-facility.html">6. Iteration</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret menu__link--active" aria-expanded="true" href="h-b-object-creation-and-initialization.html">7. Objects</a></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="h-b-object-creation-and-initialization.html">7.1 Object Creation and Initialization</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="h-c-changing-the-class-of-an-instance.html">7.2 Changing the Class of an Instance</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="h-d-reinitializing-an-instance.html">7.3 Reinitializing an Instance</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="h-e-metaobjects.html">7.4 Meta</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="h-f-slots.html">7.5 Slots</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link menu__link--active" aria-current="page" tabindex="0" href="h-g-generic-functions-and-methods.html">7.6 Generic Functions and Methods</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" tabindex="0" href="../category/77-objects-dictionary.html">7.7 Objects Dictionary</a><button aria-label="Expand sidebar category '7.7 Objects Dictionary'" type="button" class="clean-btn menu__caret"></button></div></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../category/81-structures-dictionary.html">8. Structures</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-9/j-b-condition-system-concepts.html">9. Conditions</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-10/ba-b-symbol-concepts.html">10. Symbols</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-11/bb-b-package-concepts.html">11. Packages</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-12/bc-b-number-concepts.html">12. Numbers</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-13/bd-b-character-concepts.html">13. Characters</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-14/be-b-cons-concepts.html">14. Conses</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-15/bf-b-array-concepts.html">15. Arrays</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-16/bg-b-string-concepts.html">16. Strings</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-17/bh-b-sequence-concepts.html">17. Sequences</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-18/bi-b-hash-table-concepts.html">18. Hash Tables</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-19/bj-b-overview-of-filenames.html">19. Filenames</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-20/ca-b-file-system-concepts.html">20. Files</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-21/cb-b-stream-concepts.html">21. Streams</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-22/cc-b-the-lisp-printer.html">22. Printer</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-23/cd-b-reader-concepts.html">23. Reader</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-24/ce-b-system-construction-concepts.html">24. System Construction</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-25/cf-b-the-external-environment.html">25. External Environment</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../environments.html">26. Environments</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../meta-object-protocol.html">27. Meta Object Protocol</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../data-structures.html">28. Data Structures</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../portability/trivial-packages.html">29. Portability</a></div></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="../dictionary-entries.html">dictionary-entries</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-26/intro.html">Glossary</a></div></li></ul></nav></div></div></aside><main class="docMainContainer_TBSr"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_VOVn"><div class="docItemContainer_Djhp"><article><nav class="theme-doc-breadcrumbs breadcrumbsContainer_Z_bl" aria-label="Breadcrumbs"><ul class="breadcrumbs" itemscope="" itemtype="https://schema.org/BreadcrumbList"><li class="breadcrumbs__item"><a aria-label="Home page" class="breadcrumbs__link" href="../index.html"><svg viewBox="0 0 24 24" class="breadcrumbHomeIcon_YNFT"><path d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z" fill="currentColor"></path></svg></a></li><li class="breadcrumbs__item"><span class="breadcrumbs__link">7. Objects</span><meta itemprop="position" content="1"></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item breadcrumbs__item--active"><span class="breadcrumbs__link" itemprop="name">7.6 Generic Functions and Methods</span><meta itemprop="position" content="2"></li></ul></nav><div class="tocCollapsible_ETCw theme-doc-toc-mobile tocMobile_ITEo"><button type="button" class="clean-btn tocCollapsibleButton_TO0P">On this page</button></div><div class="theme-doc-markdown markdown"><h1>7.6 Generic Functions and Methods</h1>
|
||
<!-- -->
|
||
<!-- -->
|
||
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="761-introduction-to-generic-functions">7.6.1 Introduction to Generic Functions<a href="h-g-generic-functions-and-methods.html#761-introduction-to-generic-functions" class="hash-link" aria-label="Direct link to 7.6.1 Introduction to Generic Functions" title="Direct link to 7.6.1 Introduction to Generic Functions"></a></h2>
|
||
<!-- -->
|
||
<p>A <span><i>generic function</i></span> is a function whose behavior depends on the <em>classes</em> or identities of the <span><i>arguments</i></span> supplied to it. A <em>generic function object</em> is associated with a set of <span><i>methods</i></span>, a <span><i>lambda list</i></span>, a <span><i>method combination</i></span><sub>2</sub>, and other information.</p>
|
||
<p>Like an <span><i>ordinary function</i></span>, a <span><i>generic function</i></span> takes <span><i>arguments</i></span>, performs a series of operations, and perhaps returns useful <span><i>values</i></span>. An <span><i>ordinary function</i></span> has a single body of <span><i>code</i></span> that is always <em>executed</em> when the <span><i>function</i></span> is called. A <span><i>generic function</i></span> has a set of bodies of <span><i>code</i></span> of which a subset is selected for <em>execution</em>. The selected bodies of <span><i>code</i></span> and the manner of their combination are determined by the <em>classes</em> or identities of one or more of the <span><i>arguments</i></span> to the <span><i>generic function</i></span> and by its <span><i>method combination</i></span>.</p>
|
||
<p><span><i>Ordinary functions</i></span> and <span><i>generic functions</i></span> are called with identical syntax.</p>
|
||
<p><span><i>Generic functions</i></span> are true <span><i>functions</i></span> that can be passed as <span><i>arguments</i></span> and used as the first <span><i>argument</i></span> to <span><b>funcall</b></span> and <span><b>apply</b></span>.</p>
|
||
<p>A <span><i>binding</i></span> of a <span><i>function name</i></span> to a <span><i>generic function</i></span> can be <em>established</em> in one of several ways. It can be <em>established</em> in the <span><i>global environment</i></span> by <span><b>ensure-generic-function</b></span>, <span><b>defmethod</b></span> (implicitly, due to <span><b>ensure-generic-function</b></span>) or <span><b>defgeneric</b></span> (also implicitly, due to <span><b>ensure-generic-function</b></span>). No <span><i>standardized</i></span> mechanism is provided for <em>establishing</em> a <span><i>binding</i></span> of a <span><i>function name</i></span> to a <span><i>generic function</i></span> in the <span><i>lexical environment</i></span>.</p>
|
||
<p>When a <span><b>defgeneric</b></span> form is evaluated, one of three actions is taken (due to <span><b>ensure-generic-function</b></span>):</p>
|
||
<p><em>•</em> If a generic function of the given name already exists, the existing generic function object is modified. Methods specified by the current <span><b>defgeneric</b></span> form are added, and any methods in the existing generic function that were defined by a previous <span><b>defgeneric</b></span> form are removed. Methods added by the current <span><b>defgeneric</b></span> form might replace methods defined by <span><b>defmethod</b></span>, <span><b>defclass</b></span>, <span><b>define-condition</b></span>, or <span><b>defstruct</b></span>. No other methods in the generic function are affected or replaced.</p>
|
||
<p><em>•</em> If the given name names an <span><i>ordinary function</i></span>, a <span><i>macro</i></span>, or a <span><i>special operator</i></span> , an error is signaled.</p>
|
||
<p><em>•</em> Otherwise a generic function is created with the methods specified by the method definitions in the <span><b>defgeneric</b></span> form.</p>
|
||
<p>Some <span><i>operators</i></span> permit specification of the options of a <span><i>generic function</i></span>, such as the <span><i>type</i></span> of <span><i>method combination</i></span> it uses or its <span><i>argument precedence order</i></span> . These <span><i>operators</i></span> will be referred to as “operators that specify generic function options.” The only <em>standardized operator</em> in this category is <span><b>defgeneric</b></span>.</p>
|
||
<p>Some <span><i>operators</i></span> define <span><i>methods</i></span> for a <span><i>generic function</i></span>. These <span><i>operators</i></span> will be referred to as <span><i>method-defining operators</i></span>; their associated <span><i>forms</i></span> are called <span><i>method-defining forms</i></span>. The <em>standardized method-defining operators</em> are listed in Figure 7–1.</p>
|
||
<p>|</p><p><strong>defgeneric defmethod defclass</strong> </p><p><strong>define-condition defstruct</strong></p>|<p></p>
|
||
<p>| :- |</p>
|
||
<p><strong>Figure 7–1. Standardized Method-Defining Operators</strong></p>
|
||
<p>Note that of the <em>standardized method-defining operators</em> only <span><b>defgeneric</b></span> can specify <span><i>generic function</i></span> options. <span><b>defgeneric</b></span> and any <em>implementation-defined operators</em> that can specify <span><i>generic function</i></span> options are also referred to as “operators that specify generic function options.”</p>
|
||
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="762-introduction-to-methods">7.6.2 Introduction to Methods<a href="h-g-generic-functions-and-methods.html#762-introduction-to-methods" class="hash-link" aria-label="Direct link to 7.6.2 Introduction to Methods" title="Direct link to 7.6.2 Introduction to Methods"></a></h2>
|
||
<!-- -->
|
||
<p><span><i>Methods</i></span> define the class-specific or identity-specific behavior and operations of a <span><i>generic function</i></span>.</p>
|
||
<p>A <em>method object</em> is associated with <span><i>code</i></span> that implements the method’s behavior, a sequence of <span><i>parameter specializers</i></span> that specify when the given <span><i>method</i></span> is applicable, a <span><i>lambda list</i></span>, and a sequence of <span><i>qualifiers</i></span> that are used by the method combination facility to distinguish among <span><i>methods</i></span>.</p>
|
||
<p>A method object is not a function and cannot be invoked as a function. Various mechanisms in the object system take a method object and invoke its method function, as is the case when a generic function is invoked. When this occurs it is said that the method is invoked or called.</p>
|
||
<p>A method-defining form contains the <span><i>code</i></span> that is to be run when the arguments to the generic function cause the method that it defines to be invoked. When a method-defining form is evaluated, a method object is created and one of four actions is taken:</p>
|
||
<p><em>•</em> If a <span><i>generic function</i></span> of the given name already exists and if a <em>method object</em> already exists that agrees with the new one on <span><i>parameter specializers</i></span> and <span><i>qualifiers</i></span>, the new <em>method object</em> replaces the old one. For a definition of one method agreeing with another on <span><i>parameter specializers</i></span> and <span><i>qualifiers</i></span>, see Section 7.6.3 (Agreement on Parameter Specializers and Qualifiers).</p>
|
||
<p><em>•</em> If a <span><i>generic function</i></span> of the given name already exists and if there is no <em>method object</em> that agrees with the new one on <span><i>parameter specializers</i></span> and <span><i>qualifiers</i></span>, the existing <em>generic function object</em> is modified to contain the new <em>method object</em>.</p>
|
||
<p><em>•</em> If the given <span><i>name</i></span> names an <span><i>ordinary function</i></span>, a <span><i>macro</i></span>, or a <span><i>special operator</i></span> , an error is signaled.</p>
|
||
<p><em>•</em> Otherwise a <span><i>generic function</i></span> is created with the <span><i>method</i></span> specified by the <span><i>method-defining form</i></span>.</p>
|
||
<p>If the <span><i>lambda list</i></span> of a new <span><i>method</i></span> is not <span><i>congruent</i></span> with the <span><i>lambda list</i></span> of the <span><i>generic function</i></span>, an error is signaled. If a <span><i>method-defining operator</i></span> that cannot specify <span><i>generic function</i></span> options creates a new <span><i>generic function</i></span>, a <span><i>lambda list</i></span> for that <span><i>generic function</i></span> is derived from the <span><i>lambda list</i></span> of the <span><i>method</i></span> in the <span><i>method-defining form</i></span> in such a way as to be <span><i>congruent</i></span> with it. For a discussion of <em>congruence</em>, see Section 7.6.4 (Congruent Lambda-lists for all Methods of a Generic Function).</p>
|
||
<p>Each method has a <span><i>specialized lambda list</i></span>, which determines when that method can be applied. A <span><i>specialized lambda list</i></span> is like an <span><i>ordinary lambda list</i></span> except that a specialized parameter may occur instead of the name of a required parameter. A specialized parameter is a list (<em>variable-name parameter-specializer-name</em>), where <em>parameter-specializer-name</em> is one of the following:</p>
|
||
<p>a <span><i>symbol</i></span></p>
|
||
<p>denotes a <span><i>parameter specializer</i></span> which is the <span><i>class</i></span> named by that <span><i>symbol</i></span>.</p>
|
||
<p>a <span><i>class</i></span></p>
|
||
<p>denotes a <span><i>parameter specializer</i></span> which is the <span><i>class</i></span> itself.</p>
|
||
<p>(eql <span><i>form</i></span>)</p>
|
||
<p>denotes a <span><i>parameter specializer</i></span> which satisfies the <span><i>type specifier</i></span> (eql <span><i>object</i></span>), where <span><i>object</i></span> is the result of evaluating <span><i>form</i></span>. The form <span><i>form</i></span> is evaluated in the lexical environment in which the method-defining form is evaluated. Note that <span><i>form</i></span> is evaluated only once, at the time the method is defined, not each time the generic function is called.</p>
|
||
<p><span><i>Parameter specializer names</i></span> are used in macros intended as the user-level interface (<span><b>defmethod</b></span>), while <span><i>parameter specializers</i></span> are used in the functional interface.</p>
|
||
<p>Only required parameters may be specialized, and there must be a <span><i>parameter specializer</i></span> for each required parameter. For notational simplicity, if some required parameter in a <span><i>specialized lambda list</i></span> in a method-defining form is simply a variable name, its <span><i>parameter specializer</i></span> defaults to the <span><i>class</i></span> <span><b>t</b></span>.</p>
|
||
<p>Given a generic function and a set of arguments, an applicable method is a method for that generic function whose parameter specializers are satisfied by their corresponding arguments. The following definition specifies what it means for a method to be applicable and for an argument to satisfy a <span><i>parameter specializer</i></span> .</p>
|
||
<p>Let <i>hA</i><sub>1</sub><i>, . . . , A<sub>n</sub>i</i> be the required arguments to a generic function in order. Let <i>hP</i><sub>1</sub><i>, . . . , P<sub>n</sub>i</i> be the <i>parameter specializers</i> corresponding to the required parameters of the method <i>M</i> in order. The method <i>M</i> is applicable when each <i>A<sub>i</sub></i>is of the <i>type</i> specified by the <i>type specifier P<sub>i</sub></i>. Because every valid <i>parameter specializer</i> is also a valid <i>type specifier</i> , the <i>function</i> <b>typep</b> can be used during method selection to determine whether an argument satisfies a <i>parameter specializer</i> .</p>
|
||
<p>A method all of whose <span><i>parameter specializers</i></span> are the <span><i>class</i></span> <span><b>t</b></span> is called a <span><i>default method</i></span>; it is always applicable but may be shadowed by a more specific method.</p>
|
||
<p>Methods can have <span><i>qualifiers</i></span>, which give the method combination procedure a way to distinguish among methods. A method that has one or more <span><i>qualifiers</i></span> is called a <span><i>qualified method</i></span>. A method with no <span><i>qualifiers</i></span> is called an <span><i>unqualified method</i></span>. A <span><i>qualifier</i></span> is any <span><i>non-list</i></span>. The <span><i>qualifiers</i></span> defined by the <span><i>standardized</i></span> method combination types are <span><i>symbols</i></span>.</p>
|
||
<p>In this specification, the terms “<span><i>primary method</i></span>” and “<span><i>auxiliary method</i></span>” are used to partition <span><i>methods</i></span> within a method combination type according to their intended use. In standard method combination, <span><i>primary methods</i></span> are <span><i>unqualified methods</i></span> and <span><i>auxiliary methods</i></span> are methods with a single <span><i>qualifier</i></span> that is one of <!-- -->:around<!-- -->, <!-- -->:before<!-- -->, or <!-- -->:after<!-- -->. <span><i>Methods</i></span> with these <span><i>qualifiers</i></span> are called <span><i>around methods</i></span>, <span><i>before methods</i></span>, and <span><i>after methods</i></span>, respectively. When a method combination type is defined using the short form of <span><b>define-method-combination</b></span>, <span><i>primary methods</i></span> are methods qualified with the name of the type of method combination, and auxiliary methods have the <span><i>qualifier</i></span> <!-- -->:around<!-- -->. Thus the terms “<span><i>primary method</i></span>” and “<span><i>auxiliary method</i></span>” have only a relative definition within a given method combination type.</p>
|
||
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="763-agreement-on-parameter-specializers-and-qualifiers">7.6.3 Agreement on Parameter Specializers and Qualifiers<a href="h-g-generic-functions-and-methods.html#763-agreement-on-parameter-specializers-and-qualifiers" class="hash-link" aria-label="Direct link to 7.6.3 Agreement on Parameter Specializers and Qualifiers" title="Direct link to 7.6.3 Agreement on Parameter Specializers and Qualifiers"></a></h2>
|
||
<!-- -->
|
||
<p>Two <span><i>methods</i></span> are said to agree with each other on <span><i>parameter specializers</i></span> and <span><i>qualifiers</i></span> if the following conditions hold:</p>
|
||
<p>1. Both methods have the same number of required parameters. Suppose the <i>parameter specializers</i> of the two methods are <i>P</i><sub>1<i>,</i>1</sub> <i>. . . P</i><sub>1<i>,n</i></sub> and <i>P</i><sub>2<i>,</i>1</sub> <i>. . . P</i><sub>2<i>,n</i></sub>.</p>
|
||
<p>2. For each 1 <i>≤ i ≤ n</i>, <i>P</i><sub>1<i>,i</i></sub> agrees with <i>P</i><sub>2<i>,i</i></sub>. The <i>parameter specializer P</i><sub>1<i>,i</i></sub> agrees with <i>P</i><sub>2<i>,i</i></sub> if <i>P</i><sub>1<i>,i</i></sub> and <i>P</i><sub>2<i>,i</i></sub> are the same class or if <i>P</i><sub>1<i>,i</i></sub> = (<b>eql</b> <i>object</i><sub>1</sub>), <i>P</i><sub>2<i>,i</i></sub> = (<b>eql</b> <i>object</i><sub>2</sub>), and (<b>eql</b> <i>object</i><sub>1</sub> <i>object</i><sub>2</sub>). Otherwise <i>P</i><sub>1<i>,i</i></sub> and <i>P</i><sub>2<i>,i</i></sub> do not agree.</p>
|
||
<p>3. The two <span><i>lists</i></span> of <span><i>qualifiers</i></span> are the <span><i>same</i></span> under <span><b>equal</b></span>.</p>
|
||
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="764-congruent-lambda">7.6.4 Congruent Lambda<a href="h-g-generic-functions-and-methods.html#764-congruent-lambda" class="hash-link" aria-label="Direct link to 7.6.4 Congruent Lambda" title="Direct link to 7.6.4 Congruent Lambda"></a></h2>
|
||
<!-- -->
|
||
<p>These rules define the congruence of a set of <span><i>lambda lists</i></span>, including the <span><i>lambda list</i></span> of each method for a given generic function and the <span><i>lambda list</i></span> specified for the generic function itself, if given.</p>
|
||
<p>1. Each <span><i>lambda list</i></span> must have the same number of required parameters.</p>
|
||
<p>2. Each <span><i>lambda list</i></span> must have the same number of optional parameters. Each method can supply its own default for an optional parameter.</p>
|
||
<p>3. If any <span><i>lambda list</i></span> mentions <strong>&rest</strong> or <strong>&key</strong>, each <span><i>lambda list</i></span> must mention one or both of them.</p>
|
||
<p>4. If the <span><i>generic function lambda list</i></span> mentions <strong>&key</strong>, each method must accept all of the keyword names mentioned after <strong>&key</strong>, either by accepting them explicitly, by specifying <strong>&allow-other-keys</strong>, or by specifying <strong>&rest</strong> but not <strong>&key</strong>. Each method can accept additional keyword arguments of its own. The checking of the validity of keyword names is done in the generic function, not in each method. A method is invoked as if the keyword argument pair whose name is <!-- -->:allow-other-keys<!-- --> and whose value is <span><i>true</i></span> were supplied, though no such argument pair will be passed.</p>
|
||
<p>5. The use of <strong>&allow-other-keys</strong> need not be consistent across <span><i>lambda lists</i></span>. If <strong>&allow-other-keys</strong> is mentioned in the <span><i>lambda list</i></span> of any applicable <span><i>method</i></span> or of the <span><i>generic function</i></span>, any keyword arguments may be mentioned in the call to the <span><i>generic function</i></span>.</p>
|
||
<p>6. The use of <strong>&aux</strong> need not be consistent across methods.</p>
|
||
<p>If a <span><i>method-defining operator</i></span> that cannot specify <span><i>generic function</i></span> options creates a <span><i>generic function</i></span>, and if the <span><i>lambda list</i></span> for the method mentions keyword arguments, the <span><i>lambda list</i></span> of the generic function will mention <strong>&key</strong> (but no keyword arguments).</p>
|
||
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="765-keyword-arguments-in-generic-functions-and-methods">7.6.5 Keyword Arguments in Generic Functions and Methods<a href="h-g-generic-functions-and-methods.html#765-keyword-arguments-in-generic-functions-and-methods" class="hash-link" aria-label="Direct link to 7.6.5 Keyword Arguments in Generic Functions and Methods" title="Direct link to 7.6.5 Keyword Arguments in Generic Functions and Methods"></a></h2>
|
||
<!-- -->
|
||
<p>When a generic function or any of its methods mentions <strong>&key</strong> in a <span><i>lambda list</i></span>, the specific set of keyword arguments accepted by the generic function varies according to the applicable methods. The set of keyword arguments accepted by the generic function for a particular call is the union of the keyword arguments accepted by all applicable methods and the keyword arguments mentioned after <strong>&key</strong> in the generic function definition, if any. A method that has <strong>&rest</strong> but not <strong>&key</strong> does not affect the set of acceptable keyword arguments. If the <span><i>lambda list</i></span> of any applicable method or of the generic function definition contains <strong>&allow-other-keys</strong>, all keyword arguments are accepted by the generic function.</p>
|
||
<p>The <span><i>lambda list</i></span> congruence rules require that each method accept all of the keyword arguments mentioned after <strong>&key</strong> in the generic function definition, by accepting them explicitly, by specifying <strong>&allow-other-keys</strong>, or by specifying <strong>&rest</strong> but not <strong>&key</strong>. Each method can accept additional keyword arguments of its own, in addition to the keyword arguments mentioned in the generic function definition.</p>
|
||
<p>If a <span><i>generic function</i></span> is passed a keyword argument that no applicable method accepts, an error should be signaled; see Section 3.5 (Error Checking in Function Calls).</p>
|
||
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="7651-examples-of-keyword-arguments-in-generic-functions-and-methods">7.6.5.1 Examples of Keyword Arguments in Generic Functions and Methods<a href="h-g-generic-functions-and-methods.html#7651-examples-of-keyword-arguments-in-generic-functions-and-methods" class="hash-link" aria-label="Direct link to 7.6.5.1 Examples of Keyword Arguments in Generic Functions and Methods" title="Direct link to 7.6.5.1 Examples of Keyword Arguments in Generic Functions and Methods"></a></h3>
|
||
<!-- -->
|
||
<div class="language-lisp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-lisp codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">For example, suppose there are two methods defined for width as follows: </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">defmethod</span><span class="token plain"> width </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">c</span><span class="token plain"> character-class</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> &key font</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> ...</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">defmethod</span><span class="token plain"> width </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">p</span><span class="token plain"> picture-class</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> &key pixel-size</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> ...</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">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 </span><span class="token lisp-property property" style="color:#36acaa">:pixel-size</span><span class="token plain"> is not accepted by the applicable method. </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">width</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">make-instance</span><span class="token plain"> ‘character-class </span><span class="token lisp-property property" style="color:#36acaa">:char</span><span class="token plain"> #\Q</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token lisp-property property" style="color:#36acaa">:font</span><span class="token plain"> ’baskerville </span><span class="token lisp-property property" style="color:#36acaa">:pixel-size</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">10</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">The evaluation of the following form should signal an error. </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">width</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">make-instance</span><span class="token plain"> ‘picture-class </span><span class="token lisp-property property" style="color:#36acaa">:glyph</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">glyph</span><span class="token plain"> #\Q</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token lisp-property property" style="color:#36acaa">:font</span><span class="token plain"> ’baskerville </span><span class="token lisp-property property" style="color:#36acaa">:pixel-size</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">10</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">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. </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">width</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">make-instance</span><span class="token plain"> ‘character-picture-class </span><span class="token lisp-property property" style="color:#36acaa">:char</span><span class="token plain"> #\Q</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token lisp-property property" style="color:#36acaa">:font</span><span class="token plain"> ’baskerville </span><span class="token lisp-property property" style="color:#36acaa">:pixel-size</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">10</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
|
||
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="766-method-selection-and-combination">7.6.6 Method Selection and Combination<a href="h-g-generic-functions-and-methods.html#766-method-selection-and-combination" class="hash-link" aria-label="Direct link to 7.6.6 Method Selection and Combination" title="Direct link to 7.6.6 Method Selection and Combination"></a></h2>
|
||
<!-- -->
|
||
<p>When a <span><i>generic function</i></span> is called with particular arguments, it must determine the code to execute. This code is called the <span><i>effective method</i></span> for those <span><i>arguments</i></span>. The <span><i>effective method</i></span> is a combination of the <span><i>applicable methods</i></span> in the <span><i>generic function</i></span> that <span><i>calls</i></span> some or all of the <span><i>methods</i></span>.</p>
|
||
<p>If a <span><i>generic function</i></span> is called and no <span><i>methods</i></span> are <span><i>applicable</i></span>, the <span><i>generic function</i></span> <span><b>no-applicable-method</b></span> is invoked, with the <em>results</em> from that call being used as the <em>results</em> of the call to the original <span><i>generic function</i></span>. Calling <span><b>no-applicable-method</b></span> takes precedence over checking for acceptable keyword arguments; see Section 7.6.5 (Keyword Arguments in Generic Functions and Methods).</p>
|
||
<p>When the <span><i>effective method</i></span> has been determined, it is invoked with the same <span><i>arguments</i></span> as were passed to the <span><i>generic function</i></span>. Whatever <span><i>values</i></span> it returns are returned as the <span><i>values</i></span> of the <span><i>generic function</i></span>.</p>
|
||
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="7661-determining-the-effective-method">7.6.6.1 Determining the Effective Method<a href="h-g-generic-functions-and-methods.html#7661-determining-the-effective-method" class="hash-link" aria-label="Direct link to 7.6.6.1 Determining the Effective Method" title="Direct link to 7.6.6.1 Determining the Effective Method"></a></h3>
|
||
<!-- -->
|
||
<p>The effective method is determined by the following three-step procedure:</p>
|
||
<p>1. Select the applicable methods.</p>
|
||
<p>2. Sort the applicable methods by precedence order, putting the most specific method first.</p>
|
||
<p>3. Apply method combination to the sorted list of applicable methods, producing the effective method.</p>
|
||
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="76611-selecting-the-applicable-methods">7.6.6.1.1 Selecting the Applicable Methods<a href="h-g-generic-functions-and-methods.html#76611-selecting-the-applicable-methods" class="hash-link" aria-label="Direct link to 7.6.6.1.1 Selecting the Applicable Methods" title="Direct link to 7.6.6.1.1 Selecting the Applicable Methods"></a></h4>
|
||
<!-- -->
|
||
<p>This step is described in Section 7.6.2 (Introduction to Methods).</p>
|
||
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="76612-sorting-the-applicable-methods-by-precedence-order">7.6.6.1.2 Sorting the Applicable Methods by Precedence Order<a href="h-g-generic-functions-and-methods.html#76612-sorting-the-applicable-methods-by-precedence-order" class="hash-link" aria-label="Direct link to 7.6.6.1.2 Sorting the Applicable Methods by Precedence Order" title="Direct link to 7.6.6.1.2 Sorting the Applicable Methods by Precedence Order"></a></h4>
|
||
<!-- -->
|
||
<p>To compare the precedence of two methods, their <span><i>parameter specializers</i></span> are examined in order. The default examination order is from left to right, but an alternative order may be specified by the <!-- -->:argument-precedence-order<!-- --> option to <span><b>defgeneric</b></span> or to any of the other operators that specify generic function options.</p>
|
||
<p>The corresponding <span><i>parameter specializers</i></span> from each method are compared. When a pair of <span><i>parameter specializers</i></span> agree, the next pair are compared for agreement. If all corresponding parameter specializers agree, the two methods must have different <span><i>qualifiers</i></span>; in this case, either method can be selected to precede the other. For information about agreement, see Section 7.6.3 (Agreement on Parameter Specializers and Qualifiers).</p>
|
||
<p>If some corresponding <span><i>parameter specializers</i></span> do not agree, the first pair of <span><i>parameter specializers</i></span> that do not agree determines the precedence. If both <span><i>parameter specializers</i></span> are classes, the more specific of the two methods is the method whose <span><i>parameter specializer</i></span> appears earlier in the <span><i>class precedence list</i></span> of the corresponding argument. Because of the way in which the set of applicable methods is chosen, the <span><i>parameter specializers</i></span> are guaranteed to be present in the class precedence list of the class of the argument.</p>
|
||
<p>If just one of a pair of corresponding <span><i>parameter specializers</i></span> is (eql <span><i>object</i></span>), the <span><i>method</i></span> with that <span><i>parameter specializer</i></span> precedes the other <span><i>method</i></span>. If both <span><i>parameter specializers</i></span> are <span><b>eql</b></span> <span><i>expressions</i></span>, the specializers must agree (otherwise the two <span><i>methods</i></span> would not both have been applicable to this argument).</p>
|
||
<p>The resulting list of <span><i>applicable methods</i></span> has the most specific <span><i>method</i></span> first and the least specific <span><i>method</i></span> last.</p>
|
||
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="76613-applying-method-combination-to-the-sorted-list-of-applicable-methods">7.6.6.1.3 Applying method combination to the sorted list of applicable methods<a href="h-g-generic-functions-and-methods.html#76613-applying-method-combination-to-the-sorted-list-of-applicable-methods" class="hash-link" aria-label="Direct link to 7.6.6.1.3 Applying method combination to the sorted list of applicable methods" title="Direct link to 7.6.6.1.3 Applying method combination to the sorted list of applicable methods"></a></h4>
|
||
<!-- -->
|
||
<p>In the simple case—if standard method combination is used and all applicable methods are primary methods—the effective method is the most specific method. That method can call the next most specific method by using the <span><i>function</i></span> <span><b>call-next-method</b></span>. The method that <span><b>call-next-method</b></span> will call is referred to as the <span><i>next method</i></span>. The predicate <span><b>next-method-p</b></span> tests whether a next method exists. If <span><b>call-next-method</b></span> is called and there is no next most specific method, the generic function <span><b>no-next-method</b></span> is invoked.</p>
|
||
<p>In general, the effective method is some combination of the applicable methods. It is described by a <span><i>form</i></span> that contains calls to some or all of the applicable methods, returns the value or values that will be returned as the value or values of the generic function, and optionally makes some of the methods accessible by means of <span><b>call-next-method</b></span>.</p>
|
||
<p>The role of each method in the effective method is determined by its <span><i>qualifiers</i></span> and the specificity of the method. A <span><i>qualifier</i></span> serves to mark a method, and the meaning of a <span><i>qualifier</i></span> is determined</p>
|
||
<p>by the way that these marks are used by this step of the procedure. If an applicable method has an unrecognized <span><i>qualifier</i></span> , this step signals an error and does not include that method in the effective method.</p>
|
||
<p>When standard method combination is used together with qualified methods, the effective method is produced as described in Section 7.6.6.2 (Standard Method Combination).</p>
|
||
<p>Another type of method combination can be specified by using the <!-- -->:method-combination<!-- --> option of <span><b>defgeneric</b></span> or of any of the other operators that specify generic function options. In this way this step of the procedure can be customized.</p>
|
||
<p>New types of method combination can be defined by using the <span><b>define-method-combination</b></span> <span><i>macro</i></span>.</p>
|
||
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="7662-standard-method-combination">7.6.6.2 Standard Method Combination<a href="h-g-generic-functions-and-methods.html#7662-standard-method-combination" class="hash-link" aria-label="Direct link to 7.6.6.2 Standard Method Combination" title="Direct link to 7.6.6.2 Standard Method Combination"></a></h3>
|
||
<!-- -->
|
||
<p>Standard method combination is supported by the <span><i>class</i></span> <span><b>standard-generic-function</b></span>. It is used if no other type of method combination is specified or if the built-in method combination type <strong>standard</strong> is specified.</p>
|
||
<p>Primary methods define the main action of the effective method, while auxiliary methods modify that action in one of three ways. A primary method has no method <span><i>qualifiers</i></span>.</p>
|
||
<p>An auxiliary method is a method whose <span><i>qualifier</i></span> is <!-- -->:before<!-- -->, <!-- -->:after<!-- -->, or <!-- -->:around<!-- -->. Standard method combination allows no more than one <span><i>qualifier</i></span> per method; if a method definition specifies more than one <span><i>qualifier</i></span> per method, an error is signaled.</p>
|
||
<p><em>•</em> A <span><i>before method</i></span> has the keyword <!-- -->:before<!-- --> as its only <span><i>qualifier</i></span> . A <span><i>before method</i></span> specifies <span><i>code</i></span> that is to be run before any <span><i>primary methods</i></span>.</p>
|
||
<p><em>•</em> An <span><i>after method</i></span> has the keyword <!-- -->:after<!-- --> as its only <span><i>qualifier</i></span> . An <span><i>after method</i></span> specifies <span><i>code</i></span> that is to be run after <span><i>primary methods</i></span>.</p>
|
||
<p><em>•</em> An <span><i>around method</i></span> has the keyword <!-- -->:around<!-- --> as its only <span><i>qualifier</i></span> . An <span><i>around method</i></span> specifies <span><i>code</i></span> that is to be run instead of other <span><i>applicable methods</i></span>, but which might contain explicit <span><i>code</i></span> which calls some of those <em>shadowed methods</em> (via <span><b>call-next-method</b></span>).</p>
|
||
<p>The semantics of standard method combination is as follows:</p>
|
||
<p><em>•</em> If there are any <span><i>around methods</i></span>, the most specific <span><i>around method</i></span> is called. It supplies the value or values of the generic function.</p>
|
||
<p><em>•</em> Inside the body of an <span><i>around method</i></span>, <span><b>call-next-method</b></span> can be used to call the <span><i>next method</i></span>. When the next method returns, the <span><i>around method</i></span> can execute more code, perhaps based on the returned value or values. The <span><i>generic function</i></span> <span><b>no-next-method</b></span> is invoked if <span><b>call-next-method</b></span> is used and there is no <span><i>applicable method</i></span> to call. The <span><i>function</i></span> <span><b>next-method-p</b></span> may be used to determine whether a <span><i>next method</i></span> exists.</p>
|
||
<p><em>•</em> If an <span><i>around method</i></span> invokes <span><b>call-next-method</b></span>, the next most specific <span><i>around method</i></span> is called, if one is applicable. If there are no <span><i>around methods</i></span> or if <span><b>call-next-method</b></span> is called by the least specific <span><i>around method</i></span>, the other methods are called as follows:</p>
|
||
<p>– All the <span><i>before methods</i></span> are called, in most-specific-first order. Their values are ignored. An error is signaled if <span><b>call-next-method</b></span> is used in a <span><i>before method</i></span>.</p>
|
||
<p>– The most specific primary method is called. Inside the body of a primary</p>
|
||
<p>method, <span><b>call-next-method</b></span> may be used to call the next most specific primary</p>
|
||
<p>method. When that method returns, the previous primary method can execute</p>
|
||
<p>more code, perhaps based on the returned value or values. The generic function</p>
|
||
<p><span><b>no-next-method</b></span> is invoked if <span><b>call-next-method</b></span> is used and there are no more</p>
|
||
<p>applicable primary methods. The <span><i>function</i></span> <span><b>next-method-p</b></span> may be used to</p>
|
||
<p>determine whether a <span><i>next method</i></span> exists. If <span><b>call-next-method</b></span> is not used, only</p>
|
||
<p>the most specific <span><i>primary method</i></span> is called.</p>
|
||
<p>– All the <span><i>after methods</i></span> are called in most-specific-last order. Their values are</p>
|
||
<p>ignored. An error is signaled if <span><b>call-next-method</b></span> is used in an <span><i>after method</i></span>.</p>
|
||
<p><em>•</em> If no <span><i>around methods</i></span> were invoked, the most specific primary method supplies the value or values returned by the generic function. The value or values returned by the invocation of <span><b>call-next-method</b></span> in the least specific <span><i>around method</i></span> are those returned by the most specific primary method.</p>
|
||
<p>In standard method combination, if there is an applicable method but no applicable primary method, an error is signaled.</p>
|
||
<p>The <span><i>before methods</i></span> are run in most-specific-first order while the <span><i>after methods</i></span> are run in least-specific-first order. The design rationale for this difference can be illustrated with an example. Suppose class <em>C</em><sub>1</sub> modifies the behavior of its superclass, <em>C</em><sub>2</sub>, by adding <span><i>before methods</i></span> and <span><i>after methods</i></span>. Whether the behavior of the class <em>C</em><sub>2</sub> is defined directly by methods on <em>C</em><sub>2</sub> or is inherited from its superclasses does not affect the relative order of invocation of methods on instances of the class <em>C</em><sub>1</sub>. Class <em>C</em><sub>1</sub>’s <span><i>before method</i></span> runs before all of class <em>C</em><sub>2</sub>’s methods. Class <em>C</em><sub>1</sub>’s <span><i>after method</i></span> runs after all of class <em>C</em><sub>2</sub>’s methods.</p>
|
||
<p>By contrast, all <span><i>around methods</i></span> run before any other methods run. Thus a less specific <span><i>around method</i></span> runs before a more specific primary method.</p>
|
||
<p>If only primary methods are used and if <span><b>call-next-method</b></span> is not used, only the most specific method is invoked; that is, more specific methods shadow more general ones.</p>
|
||
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="7663-declarative-method-combination">7.6.6.3 Declarative Method Combination<a href="h-g-generic-functions-and-methods.html#7663-declarative-method-combination" class="hash-link" aria-label="Direct link to 7.6.6.3 Declarative Method Combination" title="Direct link to 7.6.6.3 Declarative Method Combination"></a></h3>
|
||
<!-- -->
|
||
<p>The macro <span><b>define-method-combination</b></span> defines new forms of method combination. It provides a mechanism for customizing the production of the effective method. The default procedure for producing an effective method is described in Section 7.6.6.1 (Determining the Effective Method).</p>
|
||
<p>There are two forms of <span><b>define-method-combination</b></span>. The short form is a simple facility while the long form is more powerful and more verbose. The long form resembles <span><b>defmacro</b></span> in that the body is an expression that computes a Lisp form; it provides mechanisms for implementing arbitrary control structures within method combination and for arbitrary processing of method <span><i>qualifiers</i></span>.</p>
|
||
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="7664-built">7.6.6.4 Built<a href="h-g-generic-functions-and-methods.html#7664-built" class="hash-link" aria-label="Direct link to 7.6.6.4 Built" title="Direct link to 7.6.6.4 Built"></a></h3>
|
||
<!-- -->
|
||
<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 <!-- -->:method-combination<!-- --> option to <span><b>defgeneric</b></span> or to the <!-- -->:method-combination<!-- --> option to any of the other operators that specify generic function options.</p>
|
||
<p>The names of the built-in method combination types are listed in Figure 7–2.</p>
|
||
<p>|<strong>+ append max nconc progn and list min or standard</strong>|</p>
|
||
<p>| :- |</p>
|
||
<p><strong>Figure 7–2. Built-in Method Combination Types</strong></p>
|
||
<p>The semantics of the <strong>standard</strong> built-in method combination type is described in Section 7.6.6.2 (Standard Method Combination). The other built-in method combination types are called simple built-in method combination types.</p>
|
||
<p>The simple built-in method combination types act as though they were defined by the short form of <span><b>define-method-combination</b></span>. They recognize two roles for <span><i>methods</i></span>:</p>
|
||
<p><em>•</em> An <span><i>around method</i></span> has the keyword symbol <!-- -->:around<!-- --> as its sole <span><i>qualifier</i></span> . The meaning of <!-- -->:around<!-- --> <span><i>methods</i></span> is the same as in standard method combination. Use of the functions <span><b>call-next-method</b></span> and <span><b>next-method-p</b></span> is supported in <span><i>around methods</i></span>.</p>
|
||
<p><em>•</em> A primary method has the name of the method combination type as its sole <span><i>qualifier</i></span> . For example, the built-in method combination type and recognizes methods whose sole <span><i>qualifier</i></span> is and; these are primary methods. Use of the functions <span><b>call-next-method</b></span> and <span><b>next-method-p</b></span> is not supported in <span><i>primary methods</i></span>.</p>
|
||
<p>The semantics of the simple built-in method combination types is as follows:</p>
|
||
<p><em>•</em> If there are any <span><i>around methods</i></span>, the most specific <span><i>around method</i></span> is called. It supplies the value or values of the <span><i>generic function</i></span>.</p>
|
||
<p><em>•</em> Inside the body of an <span><i>around method</i></span>, the function <span><b>call-next-method</b></span> can be used to call the <span><i>next method</i></span>. The <span><i>generic function</i></span> <span><b>no-next-method</b></span> is invoked if <span><b>call-next-method</b></span> is used and there is no applicable method to call. The <span><i>function</i></span> <span><b>next-method-p</b></span> may be used to determine whether a <span><i>next method</i></span> exists. When the <span><i>next method</i></span> returns, the <span><i>around method</i></span> can execute more code, perhaps based on the returned value or values.</p>
|
||
<p><em>•</em> If an <span><i>around method</i></span> invokes <span><b>call-next-method</b></span>, the next most specific <span><i>around method</i></span> is called, if one is applicable. If there are no <span><i>around methods</i></span> or if <span><b>call-next-method</b></span> is called by the least specific <span><i>around method</i></span>, 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 <span><i>operator</i></span> and the call to the generic function is of the form</p>
|
||
<p>(<i>generic-function a</i><sub>1</sub> <i>. . . a<sub>n</sub></i>)</p>
|
||
<p>Let <i>M</i><sub>1</sub><i>, . . . , M<sub>k</sub></i> be the applicable primary methods in order; then the derived Lisp form is (<i>operator hM</i><sub>1</sub> <i>a</i><sub>1</sub> <i>. . . a<sub>n</sub>i. . .hM<sub>k</sub> a</i><sub>1</sub> <i>. . . a<sub>n</sub>i</i>)</p>
|
||
<p>If the expression <i>hM<sub>i</sub> a</i><sub>1</sub> <i>. . . a<sub>n</sub>i</i> is evaluated, the method <i>M<sub>i</sub></i> will be applied to the arguments <i>a</i><sub>1</sub> <i>. . . a<sub>n</sub></i>. For example, if <i>operator</i> is or, the expression <i>hM<sub>i</sub> a</i><sub>1</sub> <i>. . . a<sub>n</sub>i</i> is evaluated only if <i>hM<sub>j</sub> a</i><sub>1</sub> <i>. . . a<sub>n</sub>i</i>, 1 <i>≤ j</i> < <i>i</i>, returned nil.</p>
|
||
<p>The default order for the primary methods is <!-- -->:most-specific-first<!-- -->. However, the order can be reversed by supplying <!-- -->:most-specific-last<!-- --> as the second argument to the <!-- -->:method-combination<!-- --> option.</p>
|
||
<p>The simple built-in method combination types require exactly one <span><i>qualifier</i></span> per method. An error is signaled if there are applicable methods with no <span><i>qualifiers</i></span> or with <span><i>qualifiers</i></span> that are not supported by the method combination type. An error is signaled if there are applicable <span><i>around methods</i></span> and no applicable primary methods.</p>
|
||
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="767-inheritance-of-methods">7.6.7 Inheritance of Methods<a href="h-g-generic-functions-and-methods.html#767-inheritance-of-methods" class="hash-link" aria-label="Direct link to 7.6.7 Inheritance of Methods" title="Direct link to 7.6.7 Inheritance of Methods"></a></h2>
|
||
<!-- -->
|
||
<!-- -->
|
||
<p>A subclass inherits methods in the sense that any method applicable to all instances of a class is also applicable to all instances of any subclass of that class.</p>
|
||
<p>The inheritance of methods acts the same way regardless of which of the <span><i>method-defining operators</i></span> created the methods.</p>
|
||
<p>The inheritance of methods is described in detail in Section 7.6.6 (Method Selection and Combination).</p></div><footer class="theme-doc-footer docusaurus-mt-lg"><div class="theme-doc-footer-edit-meta-row row"><div class="col"><a href="https://github.com/lisp-docs/cl-language-reference/tree/main/docs/chap-7/h-g-generic-functions-and-methods.md" target="_blank" rel="noopener noreferrer" class="theme-edit-this-page"><svg fill="currentColor" height="20" width="20" viewBox="0 0 40 40" class="iconEdit_Z9Sw" aria-hidden="true"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>Edit this page</a></div><div class="col lastUpdated_vwxv"><span class="theme-last-updated">Last updated<!-- --> by <b>daninus14</b></span></div></div></footer></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages"><a class="pagination-nav__link pagination-nav__link--prev" href="h-f-slots.html"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">7.5 Slots</div></a><a class="pagination-nav__link pagination-nav__link--next" href="../category/77-objects-dictionary.html"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">7.7 Objects Dictionary</div></a></nav></div></div><div class="col col--3"><div class="tableOfContents_bqdL thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a href="h-g-generic-functions-and-methods.html#761-introduction-to-generic-functions" class="table-of-contents__link toc-highlight">7.6.1 Introduction to Generic Functions</a></li><li><a href="h-g-generic-functions-and-methods.html#762-introduction-to-methods" class="table-of-contents__link toc-highlight">7.6.2 Introduction to Methods</a></li><li><a href="h-g-generic-functions-and-methods.html#763-agreement-on-parameter-specializers-and-qualifiers" class="table-of-contents__link toc-highlight">7.6.3 Agreement on Parameter Specializers and Qualifiers</a></li><li><a href="h-g-generic-functions-and-methods.html#764-congruent-lambda" class="table-of-contents__link toc-highlight">7.6.4 Congruent Lambda</a></li><li><a href="h-g-generic-functions-and-methods.html#765-keyword-arguments-in-generic-functions-and-methods" class="table-of-contents__link toc-highlight">7.6.5 Keyword Arguments in Generic Functions and Methods</a><ul><li><a href="h-g-generic-functions-and-methods.html#7651-examples-of-keyword-arguments-in-generic-functions-and-methods" class="table-of-contents__link toc-highlight">7.6.5.1 Examples of Keyword Arguments in Generic Functions and Methods</a></li></ul></li><li><a href="h-g-generic-functions-and-methods.html#766-method-selection-and-combination" class="table-of-contents__link toc-highlight">7.6.6 Method Selection and Combination</a><ul><li><a href="h-g-generic-functions-and-methods.html#7661-determining-the-effective-method" class="table-of-contents__link toc-highlight">7.6.6.1 Determining the Effective Method</a><ul><li><a href="h-g-generic-functions-and-methods.html#76611-selecting-the-applicable-methods" class="table-of-contents__link toc-highlight">7.6.6.1.1 Selecting the Applicable Methods</a></li><li><a href="h-g-generic-functions-and-methods.html#76612-sorting-the-applicable-methods-by-precedence-order" class="table-of-contents__link toc-highlight">7.6.6.1.2 Sorting the Applicable Methods by Precedence Order</a></li><li><a href="h-g-generic-functions-and-methods.html#76613-applying-method-combination-to-the-sorted-list-of-applicable-methods" class="table-of-contents__link toc-highlight">7.6.6.1.3 Applying method combination to the sorted list of applicable methods</a></li></ul></li><li><a href="h-g-generic-functions-and-methods.html#7662-standard-method-combination" class="table-of-contents__link toc-highlight">7.6.6.2 Standard Method Combination</a></li><li><a href="h-g-generic-functions-and-methods.html#7663-declarative-method-combination" class="table-of-contents__link toc-highlight">7.6.6.3 Declarative Method Combination</a></li><li><a href="h-g-generic-functions-and-methods.html#7664-built" class="table-of-contents__link toc-highlight">7.6.6.4 Built</a></li></ul></li><li><a href="h-g-generic-functions-and-methods.html#767-inheritance-of-methods" class="table-of-contents__link toc-highlight">7.6.7 Inheritance of Methods</a></li></ul></div></div></div></div></main></div></div></div><footer class="footer footer--dark"><div class="container container-fluid"><div class="row footer__links"><div class="col footer__col"><div class="footer__title">Docs</div><ul class="footer__items clean-list"><li class="footer__item"><a href="../../docs/tutorial.html" target="_blank" rel="noopener noreferrer" class="footer__link-item">Common Lisp Tutorial</a></li><li class="footer__item"><a href="../index.html" target="_blank" rel="noopener noreferrer" class="footer__link-item">Common Lisp Technical Reference</a></li><li class="footer__item"><a href="../../docs/help.html" target="_blank" rel="noopener noreferrer" class="footer__link-item">Help</a></li></ul></div><div class="col footer__col"><div class="footer__title">Community</div><ul class="footer__items clean-list"><li class="footer__item"><a href="https://stackoverflow.com/questions/tagged/common-lisp" target="_blank" rel="noopener noreferrer" class="footer__link-item">Stack Overflow<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a href="https://discord.gg/hhk46CE" target="_blank" rel="noopener noreferrer" class="footer__link-item">Discord<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a href="https://www.reddit.com/r/common_lisp" target="_blank" rel="noopener noreferrer" class="footer__link-item">Reddit<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a href="https://irclog.tymoon.eu/libera/commonlisp" target="_blank" rel="noopener noreferrer" class="footer__link-item">IRC<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li></ul></div><div class="col footer__col"><div class="footer__title">More</div><ul class="footer__items clean-list"><li class="footer__item"><a href="../../blog.html" target="_blank" rel="noopener noreferrer" class="footer__link-item">Blog</a></li><li class="footer__item"><a href="https://github.com/lisp-docs/lisp-docs.github.io" target="_blank" rel="noopener noreferrer" class="footer__link-item">Tutorial and General Content GitHub<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a href="https://github.com/lisp-docs/cl-language-reference/" target="_blank" rel="noopener noreferrer" class="footer__link-item">Technical Reference GitHub<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a href="../../docs/contribute.html" target="_blank" rel="noopener noreferrer" class="footer__link-item">Contribute to the Docs</a></li></ul></div><div class="col footer__col"><div class="footer__title">Common Lisp Docs</div><ul class="footer__items clean-list"><li class="footer__item"><a href="../../docs/about.html" target="_blank" rel="noopener noreferrer" class="footer__link-item">About</a></li><li class="footer__item"><a href="../../docs/whylisp.html" target="_blank" rel="noopener noreferrer" class="footer__link-item">Why Lisp</a></li><li class="footer__item"><a href="../../docs/getting-started.html" target="_blank" rel="noopener noreferrer" class="footer__link-item">Getting Started</a></li><li class="footer__item"><a href="../../docs/faq.html" target="_blank" rel="noopener noreferrer" class="footer__link-item">FAQ</a></li><li class="footer__item"><a href="../../docs/help.html" target="_blank" rel="noopener noreferrer" class="footer__link-item">Getting Help</a></li><li class="footer__item"><a href="../../docs/howto.html" target="_blank" rel="noopener noreferrer" class="footer__link-item">How To Guides</a></li></ul></div></div><div class="footer__bottom text--center"><div class="footer__copyright">Copyright © 2024 Common Lisp Docs, MIT License (see GitHub Repo).</div></div></div></footer></div>
|
||
</body>
|
||
</html> |