1
0
Fork 0
cl-sites/lisp-docs.github.io/cl-language-reference/chap-3/d-b-evaluation.html

255 lines
No EOL
107 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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-3/d-b-evaluation" data-has-hydrated="false">
<head>
<meta charset="UTF-8">
<meta name="generator" content="Docusaurus v3.0.1">
<title data-rh="true">3.1 Evaluation | 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-3/d-b-evaluation"><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="3.1 Evaluation | Common Lisp (New) Language Reference"><meta data-rh="true" name="description" content="3.1.1 Introduction to Environments"><meta data-rh="true" property="og:description" content="3.1.1 Introduction to Environments"><link data-rh="true" rel="icon" href="../img/favicon.ico"><link data-rh="true" rel="canonical" href="d-b-evaluation.html"><link data-rh="true" rel="alternate" href="d-b-evaluation.html" hreflang="en"><link data-rh="true" rel="alternate" href="d-b-evaluation.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="d-b-evaluation.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"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret menu__link--active" aria-expanded="true" href="d-b-evaluation.html">3. Evaluation and Compilation</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 menu__link--active" aria-current="page" tabindex="0" href="d-b-evaluation.html">3.1 Evaluation</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="d-c-compilation.html">3.2 Compilation</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="d-d-declarations.html">3.3 Declarations</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="d-e-lambda-lists.html">3.4 Lambda Lists</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="d-f-error-checking-in-function-calls.html">3.5 Error Checking in Function Calls</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="d-g-traversal-rules-and-side-effects.html">3.6 Traversal Rules and Side Effects</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="d-h-destructive-operations.html">3.7 Destructive Operations</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/38-evaluation-and-compilation-dictionary.html">3.8 Evaluation and Compilation Dictionary</a><button aria-label="Expand sidebar category &#x27;3.8 Evaluation and Compilation Dictionary&#x27;" 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="../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 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-7/h-b-object-creation-and-initialization.html">7. Objects</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="../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">3. Evaluation and Compilation</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">3.1 Evaluation</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>3.1 Evaluation</h1>
<!-- -->
<p><em>Execution</em> of <span><i>code</i></span> can be accomplished by a variety of means ranging from direct interpretation of a <span><i>form</i></span> representing a <span><i>program</i></span> to invocation of <span><i>compiled code</i></span> produced by a <span><i>compiler</i></span> .</p>
<p><span><i>Evaluation</i></span> is the process by which a <span><i>program</i></span> is <em>executed</em> in Common Lisp. The mechanism of <span><i>evaluation</i></span> is manifested both implicitly through the effect of the <em>Lisp read-eval-print loop</em>, and explicitly through the presence of the <span><i>functions</i></span> <span><b>eval</b></span>, <span><b>compile</b></span>, <span><b>compile-file</b></span>, and <span><b>load</b></span>. Any of these facilities might share the same execution strategy, or each might use a different one.</p>
<p>The behavior of a <span><i>conforming program</i></span> processed by <span><b>eval</b></span> and by <span><b>compile-file</b></span> might differ; see Section 3.2.2.3 (Semantic Constraints).</p>
<p><span><i>Evaluation</i></span> can be understood in terms of a model in which an interpreter recursively traverses a <span><i>form</i></span> performing each step of the computation as it goes. This model, which describes the semantics of Common Lisp <span><i>programs</i></span>, is described in Section 3.1.2 (The Evaluation Model).</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="311-introduction-to-environments">3.1.1 Introduction to Environments<a href="d-b-evaluation.html#311-introduction-to-environments" class="hash-link" aria-label="Direct link to 3.1.1 Introduction to Environments" title="Direct link to 3.1.1 Introduction to Environments"></a></h2>
<!-- -->
<p>A <span><i>binding</i></span> is an association between a <span><i>name</i></span> and that which the name denotes. <span><i>Bindings</i></span> are <em>established</em> in a <span><i>lexical environment</i></span> or a <span><i>dynamic environment</i></span> by particular <span><i>special operators</i></span>.</p>
<p>An <span><i>environment</i></span> is a set of <span><i>bindings</i></span> and other information used during evaluation (<em>e.g.</em>, to associate meanings with names).</p>
<p><span><i>Bindings</i></span> in an <span><i>environment</i></span> are partitioned into <span><i>namespaces</i></span>. A single <span><i>name</i></span> can simultaneously have more than one associated <span><i>binding</i></span> per <span><i>environment</i></span>, but can have only one associated <span><i>binding</i></span> per <span><i>namespace</i></span>.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="3111-the-global-environment">3.1.1.1 The Global Environment<a href="d-b-evaluation.html#3111-the-global-environment" class="hash-link" aria-label="Direct link to 3.1.1.1 The Global Environment" title="Direct link to 3.1.1.1 The Global Environment"></a></h3>
<!-- -->
<p>The <span><i>global environment</i></span> is that part of an <span><i>environment</i></span> that contains <span><i>bindings</i></span> with both <span><i>indefinite scope</i></span> and <span><i>indefinite extent</i></span>. The <span><i>global environment</i></span> contains, among other things, the following:</p>
<p><em>• bindings</em> of <span><i>dynamic variables</i></span> and <span><i>constant variables</i></span>.</p>
<p><em>• bindings</em> of <span><i>functions</i></span>, <span><i>macros</i></span>, and <span><i>special operators</i></span>.</p>
<p><em>• bindings</em> of <span><i>compiler macros</i></span>.</p>
<p><em>• bindings</em> of <span><i>type</i></span> and <em>class names</em></p>
<p><em></em> information about <span><i>proclamations</i></span>.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="3112-dynamic-environments">3.1.1.2 Dynamic Environments<a href="d-b-evaluation.html#3112-dynamic-environments" class="hash-link" aria-label="Direct link to 3.1.1.2 Dynamic Environments" title="Direct link to 3.1.1.2 Dynamic Environments"></a></h3>
<!-- -->
<p>A <span><i>dynamic environment</i></span> for <span><i>evaluation</i></span> is that part of an <span><i>environment</i></span> that contains <span><i>bindings</i></span> whose duration is bounded by points of <em>establishment</em> and <em>disestablishment</em> within the execution of the <span><i>form</i></span> that established the <span><i>binding</i></span>. A <span><i>dynamic environment</i></span> contains, among other things, the following:</p>
<p><em>• bindings</em> for <span><i>dynamic variables</i></span>.</p>
<p><em></em> information about <em>active catch tags</em>.</p>
<p><em></em> information about <span><i>exit points</i></span> established by <span><b>unwind-protect</b></span>.</p>
<p><em></em> information about <em>active handlers</em> and <span><i>restarts</i></span>.</p>
<p>The <span><i>dynamic environment</i></span> that is active at any given point in the <em>execution</em> of a <span><i>program</i></span> is referred to by definite reference as “the current <span><i>dynamic environment</i></span>,” or sometimes as just “the <span><i>dynamic environment</i></span>.”</p>
<p>Within a given <span><i>namespace</i></span>, a <span><i>name</i></span> is said to be <span><i>bound</i></span> in a <span><i>dynamic environment</i></span> if there is a <span><i>binding</i></span> associated with its <span><i>name</i></span> in the <span><i>dynamic environment</i></span> or, if not, there is a <span><i>binding</i></span> associated with its name in the <span><i>global environment</i></span>.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="3113-lexical-environments">3.1.1.3 Lexical Environments<a href="d-b-evaluation.html#3113-lexical-environments" class="hash-link" aria-label="Direct link to 3.1.1.3 Lexical Environments" title="Direct link to 3.1.1.3 Lexical Environments"></a></h3>
<!-- -->
<p>A <span><i>lexical environment</i></span> for <span><i>evaluation</i></span> at some position in a <span><i>program</i></span> is that part of the <span><i>environment</i></span> that contains information having <span><i>lexical scope</i></span> within the <span><i>forms</i></span> containing that position. A <span><i>lexical environment</i></span> contains, among other things, the following:</p>
<p><em>• bindings</em> of <span><i>lexical variables</i></span> and <span><i>symbol macros</i></span>.</p>
<p><em>• bindings</em> of <span><i>functions</i></span> and <span><i>macros</i></span>. (Implicit in this is information about those <span><i>compiler macros</i></span> that are locally disabled.)</p>
<p><em>• bindings</em> of <span><i>block tags</i></span>.</p>
<p><em>• bindings</em> of <span><i>go tags</i></span>.</p>
<p><em></em> information about <span><i>declarations</i></span>.</p>
<p>The <span><i>lexical environment</i></span> that is active at any given position in a <span><i>program</i></span> being semantically processed is referred to by definite reference as “the current <span><i>lexical environment</i></span>,” or sometimes as just “the <span><i>lexical environment</i></span>.”</p>
<p>Within a given <span><i>namespace</i></span>, a <span><i>name</i></span> is said to be <span><i>bound</i></span> in a <span><i>lexical environment</i></span> if there is a <span><i>binding</i></span> associated with its <span><i>name</i></span> in the <span><i>lexical environment</i></span> or, if not, there is a <span><i>binding</i></span> associated with its name in the <span><i>global environment</i></span>.</p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="31131-the-null-lexical-environment">3.1.1.3.1 The Null Lexical Environment<a href="d-b-evaluation.html#31131-the-null-lexical-environment" class="hash-link" aria-label="Direct link to 3.1.1.3.1 The Null Lexical Environment" title="Direct link to 3.1.1.3.1 The Null Lexical Environment"></a></h4>
<!-- -->
<p>The <span><i>null lexical environment</i></span> is equivalent to the <span><i>global environment</i></span>.</p>
<p>Although in general the representation of an <span><i>environment object</i></span> is <span><i>implementation-dependent</i></span>, <span><b>nil</b></span> can be used in any situation where an <span><i>environment object</i></span> is called for in order to denote the <span><i>null lexical environment</i></span>.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="3114-environment-objects">3.1.1.4 Environment Objects<a href="d-b-evaluation.html#3114-environment-objects" class="hash-link" aria-label="Direct link to 3.1.1.4 Environment Objects" title="Direct link to 3.1.1.4 Environment Objects"></a></h3>
<!-- -->
<p>Some <span><i>operators</i></span> make use of an <span><i>object</i></span>, called an <span><i>environment object</i></span>, that represents the set of <span><i>lexical bindings</i></span> needed to perform semantic analysis on a <span><i>form</i></span> in a given <span><i>lexical environment</i></span>. The set of <span><i>bindings</i></span> in an <span><i>environment object</i></span> may be a subset of the <span><i>bindings</i></span> that would be needed to actually perform an <span><i>evaluation</i></span>; for example, <span><i>values</i></span> associated with <em>variable names</em> and <span><i>function names</i></span> in the corresponding <span><i>lexical environment</i></span> might not be available in an <span><i>environment object</i></span>.</p>
<p>The <span><i>type</i></span> and nature of an <span><i>environment object</i></span> is <span><i>implementation-dependent</i></span>. The <span><i>values</i></span> of <span><i>environment parameters</i></span> to <span><i>macro functions</i></span> are examples of <span><i>environment objects</i></span>.</p>
<p>The <span><i>object</i></span> <span><b>nil</b></span> when used as an <span><i>environment object</i></span> denotes the <span><i>null lexical environment</i></span>; see Section 3.1.1.3.1 (The Null Lexical Environment).</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="312-the-evaluation-model">3.1.2 The Evaluation Model<a href="d-b-evaluation.html#312-the-evaluation-model" class="hash-link" aria-label="Direct link to 3.1.2 The Evaluation Model" title="Direct link to 3.1.2 The Evaluation Model"></a></h2>
<!-- -->
<p>A Common Lisp system evaluates <span><i>forms</i></span> with respect to lexical, dynamic, and global <span><i>environments</i></span>. The following sections describe the components of the Common Lisp evaluation model.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="3121-form-evaluation">3.1.2.1 Form Evaluation<a href="d-b-evaluation.html#3121-form-evaluation" class="hash-link" aria-label="Direct link to 3.1.2.1 Form Evaluation" title="Direct link to 3.1.2.1 Form Evaluation"></a></h3>
<!-- -->
<p><span><i>Forms</i></span> fall into three categories: <span><i>symbols</i></span>, <em>conses</em>, and <span><i>self-evaluating objects</i></span>. The following sections explain these categories.</p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="31211-symbols-as-forms">3.1.2.1.1 Symbols as Forms<a href="d-b-evaluation.html#31211-symbols-as-forms" class="hash-link" aria-label="Direct link to 3.1.2.1.1 Symbols as Forms" title="Direct link to 3.1.2.1.1 Symbols as Forms"></a></h4>
<!-- -->
<p>If a <span><i>form</i></span> is a <span><i>symbol</i></span>, then it is either a <span><i>symbol macro</i></span> or a <span><i>variable</i></span>.</p>
<p>The <span><i>symbol</i></span> names a <span><i>symbol macro</i></span> if there is a <span><i>binding</i></span> of the <span><i>symbol</i></span> as a <span><i>symbol macro</i></span> in the current <span><i>lexical environment</i></span> (see <span><b>define-symbol-macro</b></span> and <span><b>symbol-macrolet</b></span>). If the <span><i>symbol</i></span> is a <span><i>symbol macro</i></span>, its expansion function is obtained. The expansion function is a function of two arguments, and is invoked by calling the <span><i>macroexpand hook</i></span> with the expansion function as its</p>
<p>first argument, the <span><i>symbol</i></span> as its second argument, and an <span><i>environment object</i></span> (corresponding to the current <span><i>lexical environment</i></span>) as its third argument. The <span><i>macroexpand hook</i></span>, in turn, calls the expansion function with the <span><i>form</i></span> as its first argument and the <span><i>environment</i></span> as its second argument. The <span><i>value</i></span> of the expansion function, which is passed through by the <span><i>macroexpand hook</i></span>, is a <span><i>form</i></span>. This resulting <span><i>form</i></span> is processed in place of the original <span><i>symbol</i></span>.</p>
<p>If a <span><i>form</i></span> is a <span><i>symbol</i></span> that is not a <span><i>symbol macro</i></span>, then it is the <span><i>name</i></span> of a <span><i>variable</i></span>, and the <span><i>value</i></span> of that <span><i>variable</i></span> is returned. There are three kinds of variables: <span><i>lexical variables</i></span>, <span><i>dynamic variables</i></span>,</p>
<p>and <span><i>constant variables</i></span>. A <span><i>variable</i></span> can store one <span><i>object</i></span>. The main operations on a <span><i>variable</i></span> are to <span><i>read</i></span> <sub>1</sub> and to <span><i>write</i></span><sub>1</sub> its <span><i>value</i></span>.</p>
<p>An error of <span><i>type</i></span> <span><b>unbound-variable</b></span> should be signaled if an <span><i>unbound variable</i></span> is referenced.</p>
<p><span><i>Non-constant variables</i></span> can be <em>assigned</em> by using <span><b>setq</b></span> or <span><i>bound</i></span> <sub>3</sub> by using <span><b>let</b></span>. Figure 31 lists some <span><i>defined names</i></span> that are applicable to assigning, binding, and defining <span><i>variables</i></span>.</p>
<p>|</p><p><strong>boundp let progv</strong> </p><p><strong>defconstant let* psetq</strong> </p><p><strong>defparameter makunbound set</strong> </p><p><strong>defvar multiple-value-bind setq</strong> </p><p><strong>lambda multiple-value-setq symbol-value</strong></p>|<p></p>
<p>| :- |</p>
<p><strong>Figure 31. Some Defined Names Applicable to Variables</strong></p>
<p>The following is a description of each kind of variable.</p>
<h5 class="anchor anchorWithStickyNavbar_LWe7" id="312111-lexical-variables">3.1.2.1.1.1 Lexical Variables<a href="d-b-evaluation.html#312111-lexical-variables" class="hash-link" aria-label="Direct link to 3.1.2.1.1.1 Lexical Variables" title="Direct link to 3.1.2.1.1.1 Lexical Variables"></a></h5>
<!-- -->
<p>A <span><i>lexical variable</i></span> is a <span><i>variable</i></span> that can be referenced only within the <span><i>lexical scope</i></span> of the <span><i>form</i></span> that establishes that <span><i>variable</i></span>; <span><i>lexical variables</i></span> have <span><i>lexical scope</i></span>. Each time a <span><i>form</i></span> creates a <span><i>lexical binding</i></span> of a <span><i>variable</i></span>, a <em>fresh binding</em> is <em>established</em>.</p>
<p>Within the <span><i>scope</i></span> of a <span><i>binding</i></span> for a <em>lexical variable name</em>, uses of that <span><i>name</i></span> as a <span><i>variable</i></span> are considered to be references to that <span><i>binding</i></span> except where the <span><i>variable</i></span> is <em>shadowed</em> <sub>2</sub> by a <span><i>form</i></span> that <em>establishes</em> a <em>fresh binding</em> for that <em>variable name</em>, or by a <span><i>form</i></span> that locally <span><i>declares</i></span> the <span><i>name</i></span> <span><b>special</b></span>.</p>
<p>A <span><i>lexical variable</i></span> always has a <span><i>value</i></span>. There is no <span><i>operator</i></span> that introduces a <span><i>binding</i></span> for a <span><i>lexical variable</i></span> without giving it an initial <span><i>value</i></span>, nor is there any <span><i>operator</i></span> that can make a <span><i>lexical variable</i></span> be <span><i>unbound</i></span>.</p>
<p><span><i>Bindings</i></span> of <span><i>lexical variables</i></span> are found in the <span><i>lexical environment</i></span>.</p>
<h5 class="anchor anchorWithStickyNavbar_LWe7" id="312112-dynamic-variables">3.1.2.1.1.2 Dynamic Variables<a href="d-b-evaluation.html#312112-dynamic-variables" class="hash-link" aria-label="Direct link to 3.1.2.1.1.2 Dynamic Variables" title="Direct link to 3.1.2.1.1.2 Dynamic Variables"></a></h5>
<!-- -->
<p>A <span><i>variable</i></span> is a <span><i>dynamic variable</i></span> if one of the following conditions hold:</p>
<p><em></em> It is locally declared or globally proclaimed <span><b>special</b></span>.</p>
<p><em></em> It occurs textually within a <span><i>form</i></span> that creates a <span><i>dynamic binding</i></span> for a <span><i>variable</i></span> of the <em>same name</em>, and the <span><i>binding</i></span> is not <em>shadowed</em> <sub>2</sub> by a <span><i>form</i></span> that creates a <span><i>lexical binding</i></span> of the same <em>variable name</em>.</p>
<p>A <span><i>dynamic variable</i></span> can be referenced at any time in any <span><i>program</i></span>; there is no textual limitation on references to <span><i>dynamic variables</i></span>. At any given time, all <span><i>dynamic variables</i></span> with a given name refer to exactly one <span><i>binding</i></span>, either in the <span><i>dynamic environment</i></span> or in the <span><i>global environment</i></span>.</p>
<p>The <span><i>value</i></span> part of the <span><i>binding</i></span> for a <span><i>dynamic variable</i></span> might be empty; in this case, the <span><i>dynamic variable</i></span> is said to have no <span><i>value</i></span>, or to be <span><i>unbound</i></span>. A <span><i>dynamic variable</i></span> can be made <span><i>unbound</i></span> by using <span><b>makunbound</b></span>.</p>
<p>The effect of <span><i>binding</i></span> a <span><i>dynamic variable</i></span> is to create a new <span><i>binding</i></span> to which all references to that <span><i>dynamic variable</i></span> in any <span><i>program</i></span> refer for the duration of the <span><i>evaluation</i></span> of the <span><i>form</i></span> that creates the <span><i>dynamic binding</i></span>.</p>
<p>A <span><i>dynamic variable</i></span> can be referenced outside the <span><i>dynamic extent</i></span> of a <span><i>form</i></span> that <span><i>binds</i></span> it. Such a <span><i>variable</i></span> is sometimes called a “global variable” but is still in all respects just a <span><i>dynamic variable</i></span> whose <span><i>binding</i></span> happens to exist in the <span><i>global environment</i></span> rather than in some <span><i>dynamic environment</i></span>.</p>
<p>A <span><i>dynamic variable</i></span> is <span><i>unbound</i></span> unless and until explicitly assigned a value, except for those variables whose initial value is defined in this specification or by an <span><i>implementation</i></span>.</p>
<h5 class="anchor anchorWithStickyNavbar_LWe7" id="312113-constant-variables">3.1.2.1.1.3 Constant Variables<a href="d-b-evaluation.html#312113-constant-variables" class="hash-link" aria-label="Direct link to 3.1.2.1.1.3 Constant Variables" title="Direct link to 3.1.2.1.1.3 Constant Variables"></a></h5>
<!-- -->
<p>Certain variables, called <span><i>constant variables</i></span>, are reserved as “named constants.” The consequences are undefined if an attempt is made to assign a value to, or create a <span><i>binding</i></span> for a <span><i>constant variable</i></span>, except that a compatible redefinition of a <span><i>constant variable</i></span> using <span><b>defconstant</b></span> is permitted; see the <span><i>macro</i></span> <span><b>defconstant</b></span>.</p>
<p><span><i>Keywords</i></span>, <span><i>symbols</i></span> defined by Common Lisp or the <span><i>implementation</i></span> as constant (such as <span><b>nil</b></span>, <span><b>t</b></span>, and <strong>pi</strong>), and <span><i>symbols</i></span> declared as constant using <span><b>defconstant</b></span> are <span><i>constant variables</i></span>.</p>
<h5 class="anchor anchorWithStickyNavbar_LWe7" id="312114-symbols-naming-both-lexical-and-dynamic-variables">3.1.2.1.1.4 Symbols Naming Both Lexical and Dynamic Variables<a href="d-b-evaluation.html#312114-symbols-naming-both-lexical-and-dynamic-variables" class="hash-link" aria-label="Direct link to 3.1.2.1.1.4 Symbols Naming Both Lexical and Dynamic Variables" title="Direct link to 3.1.2.1.1.4 Symbols Naming Both Lexical and Dynamic Variables"></a></h5>
<!-- -->
<p>The same <span><i>symbol</i></span> can name both a <span><i>lexical variable</i></span> and a <span><i>dynamic variable</i></span>, but never in the same <span><i>lexical environment</i></span>.</p>
<p>In the following example, the <span><i>symbol</i></span> x is used, at different times, as the <span><i>name</i></span> of a <span><i>lexical variable</i></span> and as the <span><i>name</i></span> of a <span><i>dynamic variable</i></span>.</p>
<p>(let ((x 1)) ;Binds a special variable X</p>
<p>(declare (special x))</p>
<p>(let ((x 2)) ;Binds a lexical variable X</p>
<p>(+ x ;Reads a lexical variable X</p>
<p>(locally (declare (special x))</p>
<p>x)))) ;Reads a special variable X</p>
<p>→ 3</p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="31212-conses-as-forms">3.1.2.1.2 Conses as Forms<a href="d-b-evaluation.html#31212-conses-as-forms" class="hash-link" aria-label="Direct link to 3.1.2.1.2 Conses as Forms" title="Direct link to 3.1.2.1.2 Conses as Forms"></a></h4>
<!-- -->
<p>A <span><i>cons</i></span> that is used as a <span><i>form</i></span> is called a <span><i>compound form</i></span>.</p>
<p>If the <span><i>car</i></span> of that <span><i>compound form</i></span> is a <span><i>symbol</i></span>, that <span><i>symbol</i></span> is the <span><i>name</i></span> of an <span><i>operator</i></span> , and the <span><i>form</i></span> is either a <span><i>special form</i></span>, a <span><i>macro form</i></span>, or a <span><i>function form</i></span>, depending on the <em>function binding</em> of the <span><i>operator</i></span> in the current <span><i>lexical environment</i></span>. If the <span><i>operator</i></span> is neither a <span><i>special operator</i></span></p>
<p>nor a <span><i>macro name</i></span>, it is assumed to be a <span><i>function name</i></span> (even if there is no definition for such a <span><i>function</i></span>).</p>
<p>If the <span><i>car</i></span> of the <span><i>compound form</i></span> is not a <span><i>symbol</i></span>, then that <span><i>car</i></span> must be a <span><i>lambda expression</i></span>, in which case the <span><i>compound form</i></span> is a <span><i>lambda form</i></span>.</p>
<p>How a <span><i>compound form</i></span> is processed depends on whether it is classified as a <span><i>special form</i></span>, a <span><i>macro form</i></span>, a <span><i>function form</i></span>, or a <span><i>lambda form</i></span>.</p>
<h5 class="anchor anchorWithStickyNavbar_LWe7" id="312121-special-forms">3.1.2.1.2.1 Special Forms<a href="d-b-evaluation.html#312121-special-forms" class="hash-link" aria-label="Direct link to 3.1.2.1.2.1 Special Forms" title="Direct link to 3.1.2.1.2.1 Special Forms"></a></h5>
<!-- -->
<p>A <span><i>special form</i></span> is a <span><i>form</i></span> with special syntax, special evaluation rules, or both, possibly manipulating the evaluation environment, control flow, or both. A <span><i>special operator</i></span> has access to the current <span><i>lexical environment</i></span> and the current <span><i>dynamic environment</i></span>. Each <span><i>special operator</i></span> defines the manner in which its <span><i>subexpressions</i></span> are treated—which are <span><i>forms</i></span>, which are special syntax, <em>etc.</em></p>
<p>Some <span><i>special operators</i></span> create new lexical or dynamic <span><i>environments</i></span> for use during the <span><i>evaluation</i></span> of <span><i>subforms</i></span> of the <span><i>special form</i></span>. For example, <span><b>block</b></span> creates a new <span><i>lexical environment</i></span> that is the same as the one in force at the point of evaluation of the <span><b>block</b></span> <span><i>form</i></span> with the addition of a <span><i>binding</i></span> of the <span><b>block</b></span> name to an <span><i>exit point</i></span> from the <span><b>block</b></span>.</p>
<p>The set of <em>special operator names</em> is fixed in Common Lisp; no way is provided for the user to define a <span><i>special operator</i></span> . Figure 32 lists all of the Common Lisp <span><i>symbols</i></span> that have definitions as <span><i>special operators</i></span>.</p>
<p>|</p><p><strong>block let* return-from</strong> </p><p><strong>catch load-time-value setq</strong> </p><p><strong>eval-when locally symbol-macrolet flet macrolet tagbody</strong> </p><p><strong>function multiple-value-call the</strong> </p><p><strong>go multiple-value-prog1 throw</strong> </p><p><strong>if progn unwind-protect labels progv</strong> </p><p><strong>let quote</strong></p>|<p></p>
<p>| :- |</p>
<p><strong>Figure 32. Common Lisp Special Operators</strong></p>
<h5 class="anchor anchorWithStickyNavbar_LWe7" id="312122-macro-forms">3.1.2.1.2.2 Macro Forms<a href="d-b-evaluation.html#312122-macro-forms" class="hash-link" aria-label="Direct link to 3.1.2.1.2.2 Macro Forms" title="Direct link to 3.1.2.1.2.2 Macro Forms"></a></h5>
<!-- -->
<p>If the <span><i>operator</i></span> names a <span><i>macro</i></span>, its associated <span><i>macro function</i></span> is applied to the entire <span><i>form</i></span> and the result of that application is used in place of the original <span><i>form</i></span>.</p>
<p>Specifically, a <span><i>symbol</i></span> names a <span><i>macro</i></span> in a given <span><i>lexical environment</i></span> if <span><b>macro-function</b></span> is <span><i>true</i></span> of the <span><i>symbol</i></span> and that <span><i>environment</i></span>. The <span><i>function</i></span> returned by <span><b>macro-function</b></span> is a <span><i>function</i></span> of two arguments, called the expansion function. The expansion function is invoked by calling the <span><i>macroexpand hook</i></span> with the expansion function as its first argument, the entire <span><i>macro form</i></span> as its</p>
<p>second argument, and an <span><i>environment object</i></span> (corresponding to the current <span><i>lexical environment</i></span>) as its third argument. The <span><i>macroexpand hook</i></span>, in turn, calls the expansion function with the <span><i>form</i></span> as its first argument and the <span><i>environment</i></span> as its second argument. The <span><i>value</i></span> of the expansion function, which is passed through by the <span><i>macroexpand hook</i></span>, is a <span><i>form</i></span>. The returned <span><i>form</i></span> is <em>evaluated</em> in place of the original <span><i>form</i></span>.</p>
<p>The consequences are undefined if a <span><i>macro function</i></span> destructively modifies any part of its <span><i>form</i></span> argument.</p>
<p>A <span><i>macro name</i></span> is not a <span><i>function designator</i></span> , and cannot be used as the <span><i>function</i></span> argument to <span><i>functions</i></span> such as <span><b>apply</b></span>, <span><b>funcall</b></span>, or <span><b>map</b></span>.</p>
<p>An <span><i>implementation</i></span> is free to implement a Common Lisp <span><i>special operator</i></span> as a <span><i>macro</i></span>. An <span><i>implementation</i></span> is free to implement any <em>macro operator</em> as a <span><i>special operator</i></span> , but only if an equivalent definition of the <span><i>macro</i></span> is also provided.</p>
<p>Figure 33 lists some <span><i>defined names</i></span> that are applicable to <span><i>macros</i></span>.</p>
<p>|<strong>*macroexpand-hook* macro-function macroexpand-1 defmacro macroexpand macrolet</strong>|</p>
<p>| :- |</p>
<p><strong>Figure 33. Defined names applicable to macros</strong></p>
<h5 class="anchor anchorWithStickyNavbar_LWe7" id="312123-function-forms">3.1.2.1.2.3 Function Forms<a href="d-b-evaluation.html#312123-function-forms" class="hash-link" aria-label="Direct link to 3.1.2.1.2.3 Function Forms" title="Direct link to 3.1.2.1.2.3 Function Forms"></a></h5>
<!-- -->
<p>If the <span><i>operator</i></span> is a <span><i>symbol</i></span> naming a <span><i>function</i></span>, the <span><i>form</i></span> represents a <em>function form</em>, and the <span><i>cdr</i></span> of the list contains the <span><i>forms</i></span> which when evaluated will supply the arguments passed to the <span><i>function</i></span>.</p>
<p>When a <em>function name</em> is not defined, an error of <span><i>type</i></span> <span><b>undefined-function</b></span> should be signaled at run time; see Section 3.2.2.3 (Semantic Constraints).</p>
<p>A <em>function form</em> is evaluated as follows:</p>
<p>The <span><i>subforms</i></span> in the <span><i>cdr</i></span> of the original <span><i>form</i></span> are evaluated in left-to-right order in the current lexical and dynamic <span><i>environments</i></span>. The <em>primary value</em> of each such <span><i>evaluation</i></span> becomes an <span><i>argument</i></span> to the named <span><i>function</i></span>; any additional <span><i>values</i></span> returned by the <span><i>subforms</i></span> are discarded.</p>
<p>The <em>functional value</em> of the <span><i>operator</i></span> is retrieved from the <em>lexical environment</em>, and that <span><i>function</i></span> is invoked with the indicated arguments.</p>
<p>Although the order of <span><i>evaluation</i></span> of the <em>argument subforms</em> themselves is strictly left-to-right, it is not specified whether the definition of the <span><i>operator</i></span> in a <em>function form</em> is looked up before the <span><i>evaluation</i></span> of the <em>argument subforms</em>, after the <span><i>evaluation</i></span> of the <em>argument subforms</em>, or between the <span><i>evaluation</i></span> of any two <em>argument subforms</em> if there is more than one such <em>argument subform</em>. For example, the following might return 23 or 24.</p>
<p>(defun foo (x) (+ x 3))</p>
<p>(defun bar () (setf (symbol-function foo) #(lambda (x) (+ x 4))))</p>
<p>(foo (progn (bar) 20))</p>
<p>A <span><i>binding</i></span> for a <span><i>function name</i></span> can be <em>established</em> in one of several ways. A <em>bind ing</em> for a <span><i>function name</i></span> in the <span><i>global environment</i></span> can be <em>established</em> by <span><b>defun</b></span>, <span><b>setf</b></span> of <span><b>fdefinition</b></span>, <span><b>setf</b></span> of <span><b>symbol-function</b></span>, <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>. A <span><i>binding</i></span> for a <span><i>function name</i></span> in the <span><i>lexical environment</i></span> can be <em>established</em> by <span><b>flet</b></span> or <span><b>labels</b></span>.</p>
<p>Figure 34 lists some <span><i>defined names</i></span> that are applicable to <span><i>functions</i></span>.</p>
<p>|</p><p><strong>apply fdefinition mapcan</strong> </p><p><strong>call-arguments-limit flet mapcar</strong> </p><p><strong>complement fmakunbound mapcon</strong> </p><p><strong>constantly funcall mapl</strong> </p><p><strong>defgeneric function maplist</strong> </p><p><strong>defmethod functionp multiple-value-call defun labels reduce</strong> </p><p><strong>fboundp map symbol-function</strong></p>|<p></p>
<p>| :- |</p>
<p><strong>Figure 34. Some function-related defined names</strong></p>
<h5 class="anchor anchorWithStickyNavbar_LWe7" id="312124-lambda-forms">3.1.2.1.2.4 Lambda Forms<a href="d-b-evaluation.html#312124-lambda-forms" class="hash-link" aria-label="Direct link to 3.1.2.1.2.4 Lambda Forms" title="Direct link to 3.1.2.1.2.4 Lambda Forms"></a></h5>
<!-- -->
<p>A <span><i>lambda form</i></span> is similar to a <span><i>function form</i></span>, except that the <span><i>function name</i></span> is replaced by a <span><i>lambda expression</i></span>.</p>
<p>A <span><i>lambda form</i></span> is equivalent to using <em>funcall</em> of a <span><i>lexical closure</i></span> of the <span><i>lambda expression</i></span> on the given <span><i>arguments</i></span>. (In practice, some compilers are more likely to produce inline code for a <span><i>lambda form</i></span> than for an arbitrary named function that has been declared <span><b>inline</b></span>; however, such a difference is not semantic.)</p>
<p>For further information, see Section 3.1.3 (Lambda Expressions).</p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="31213-self">3.1.2.1.3 Self<a href="d-b-evaluation.html#31213-self" class="hash-link" aria-label="Direct link to 3.1.2.1.3 Self" title="Direct link to 3.1.2.1.3 Self"></a></h4>
<!-- -->
<p>A <span><i>form</i></span> that is neither a <span><i>symbol</i></span> nor a <span><i>cons</i></span> is defined to be a <em>self-evaluating object<span><i>. </i></span>Evaluating</em> such an <em>object yields</em> the <em>same object</em> as a result.</p>
<p>Certain specific <span><i>symbols</i></span> and <em>conses</em> might also happen to be “self-evaluating” but only as a special case of a more general set of rules for the <span><i>evaluation</i></span> of <span><i>symbols</i></span> and <em>conses</em>; such <span><i>objects</i></span> are not considered to be <span><i>self-evaluating objects</i></span>.</p>
<p>The consequences are undefined if <em>literal objects</em> (including <span><i>self-evaluating objects</i></span>) are destructively modified.</p>
<h5 class="anchor anchorWithStickyNavbar_LWe7" id="312131-examples-of-self">3.1.2.1.3.1 Examples of Self<a href="d-b-evaluation.html#312131-examples-of-self" class="hash-link" aria-label="Direct link to 3.1.2.1.3.1 Examples of Self" title="Direct link to 3.1.2.1.3.1 Examples of Self"></a></h5>
<!-- -->
<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">*Numbers*, *pathnames*, and *arrays* are examples of *self-evaluating objects*. </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token number" style="color:#36acaa">3</span><span class="token plain"></span><span class="token number" style="color:#36acaa">3</span><span class="token plain"> </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">#c</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">2/3 5/8</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> → #C</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">2/3 5/8</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">#p</span><span class="token string" style="color:#e3116c">&quot;S:[BILL]</span><span class="token string argument" style="color:#e3116c">OTHELLO</span><span class="token string" style="color:#e3116c">.TXT&quot;</span><span class="token plain"> → #P</span><span class="token string" style="color:#e3116c">&quot;S:[BILL]</span><span class="token string argument" style="color:#e3116c">OTHELLO</span><span class="token string" style="color:#e3116c">.TXT&quot;</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">a</span><span class="token plain"> b c</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 car">A</span><span class="token plain"> B C</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 string" style="color:#e3116c">&quot;fred smith&quot;</span><span class="token plain"></span><span class="token string" style="color:#e3116c">&quot;fred smith&quot;</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="313-lambda-expressions">3.1.3 Lambda Expressions<a href="d-b-evaluation.html#313-lambda-expressions" class="hash-link" aria-label="Direct link to 3.1.3 Lambda Expressions" title="Direct link to 3.1.3 Lambda Expressions"></a></h2>
<!-- -->
<p>In a <span><i>lambda expression</i></span>, the body is evaluated in a lexical <span><i>environment</i></span> that is formed by adding the <span><i>binding</i></span> of each <span><i>parameter</i></span> in the <span><i>lambda list</i></span> with the corresponding <span><i>value</i></span> from the <span><i>arguments</i></span> to the current lexical <span><i>environment</i></span>.</p>
<p>For further discussion of how <span><i>bindings</i></span> are <em>established</em> based on the <span><i>lambda list</i></span>, see Section 3.4 (Lambda Lists).</p>
<p>The body of a <span><i>lambda expression</i></span> is an <span><i>implicit progn</i></span>; the <span><i>values</i></span> it returns are returned by the <span><i>lambda expression</i></span>.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="314-closures-and-lexical-binding">3.1.4 Closures and Lexical Binding<a href="d-b-evaluation.html#314-closures-and-lexical-binding" class="hash-link" aria-label="Direct link to 3.1.4 Closures and Lexical Binding" title="Direct link to 3.1.4 Closures and Lexical Binding"></a></h2>
<!-- -->
<p>A <span><i>lexical closure</i></span> is a <span><i>function</i></span> that can refer to and alter the values of <em>lexical bindings established</em> by <em>binding forms</em> that textually include the function definition.</p>
<p>Consider this code, where x is not declared <span><b>special</b></span>:</p>
<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 punctuation" style="color:#393A34">(</span><span class="token defun keyword" style="color:#00009f">defun</span><span class="token defun"> </span><span class="token defun function" style="color:#d73a49">two-funs</span><span class="token defun"> </span><span class="token defun punctuation" style="color:#393A34">(</span><span class="token defun arguments argument variable" style="color:#36acaa">x</span><span class="token defun 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">list</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">function</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token lambda keyword" style="color:#00009f">lambda</span><span class="token lambda"> </span><span class="token lambda punctuation" style="color:#393A34">(</span><span class="token lambda arguments"></span><span class="token lambda punctuation" style="color:#393A34">)</span><span class="token plain"> x</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 punctuation" style="color:#393A34">(</span><span class="token car">function</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token lambda keyword" style="color:#00009f">lambda</span><span class="token lambda"> </span><span class="token lambda punctuation" style="color:#393A34">(</span><span class="token lambda arguments argument variable" style="color:#36acaa">y</span><span class="token lambda punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">setq</span><span class="token plain"> x y</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</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 punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">setq</span><span class="token plain"> funs </span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">two-funs</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">6</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 punctuation" style="color:#393A34">(</span><span class="token car">funcall</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">car</span><span class="token plain"> funs</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><span class="token number" style="color:#36acaa">6</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">funcall</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">cadr</span><span class="token plain"> funs</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">43</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><span class="token number" style="color:#36acaa">43</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">funcall</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">car</span><span class="token plain"> funs</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><span class="token number" style="color:#36acaa">43</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>
<p>The <span><b>function</b></span> <span><i>special form</i></span> coerces a <span><i>lambda expression</i></span> into a <span><i>closure</i></span> in which the <span><i>lexical environment</i></span> in effect when the <span><i>special form</i></span> is evaluated is captured along with the <span><i>lambda expression</i></span>.</p>
<p>The function two-funs returns a <span><i>list</i></span> of two <span><i>functions</i></span>, each of which refers to the <span><i>binding</i></span> of the variable x created on entry to the function two-funs when it was called. This variable has the value 6 initially, but <span><b>setq</b></span> can alter this <span><i>binding</i></span>. The <span><i>lexical closure</i></span> created for the first <span><i>lambda expression</i></span> does not “snapshot” the <span><i>value</i></span> 6 for x when the <span><i>closure</i></span> is created; rather it captures the <span><i>binding</i></span> of x. The second <span><i>function</i></span> can be used to alter the <span><i>value</i></span> in the same (captured) <span><i>binding</i></span> (to 43, in the example), and this altered variable binding then affects the value returned by the first <span><i>function</i></span>.</p>
<p>In situations where a <span><i>closure</i></span> of a <span><i>lambda expression</i></span> over the same set of <span><i>bindings</i></span> may be produced more than once, the various resulting <span><i>closures</i></span> may or may not be <span><i>identical</i></span>, at the discretion of the <span><i>implementation</i></span>. That is, two <span><i>functions</i></span> that are behaviorally indistinguishable might or might not be <span><i>identical</i></span>. Two <span><i>functions</i></span> that are behaviorally distinguishable are <span><i>distinct</i></span>. For example:</p>
<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 punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">let</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">x</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">5</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 car">funs</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</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 punctuation" style="color:#393A34">(</span><span class="token car">dotimes</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">j</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"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">push</span><span class="token plain"> #</span><span class="token punctuation" style="color:#393A34">(</span><span class="token lambda keyword" style="color:#00009f">lambda</span><span class="token lambda"> </span><span class="token lambda punctuation" style="color:#393A34">(</span><span class="token lambda arguments argument variable" style="color:#36acaa">z</span><span class="token lambda 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 keyword" style="color:#00009f">if</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">null</span><span class="token plain"> z</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 keyword" style="color:#00009f">setq</span><span class="token plain"> x </span><span class="token number" style="color:#36acaa">0</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 car">+</span><span class="token plain"> x z</span><span class="token punctuation" style="color:#393A34">)</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"> funs</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"> funs</span><span class="token punctuation" style="color:#393A34">)</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>
<p>The result of the above <span><i>form</i></span> is a <span><i>list</i></span> of ten <span><i>closures</i></span>. Each requires only the <span><i>binding</i></span> of x. It is the same <span><i>binding</i></span> in each case, but the ten <em>closure objects</em> might or might not be <span><i>identical</i></span>. On the other hand, the result of the <span><i>form</i></span></p>
<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 punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">let</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">funs</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</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 punctuation" style="color:#393A34">(</span><span class="token car">dotimes</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">j</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"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">let</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">x</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">5</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 punctuation" style="color:#393A34">(</span><span class="token car">push</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">function</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token lambda keyword" style="color:#00009f">lambda</span><span class="token lambda"> </span><span class="token lambda punctuation" style="color:#393A34">(</span><span class="token lambda arguments argument variable" style="color:#36acaa">z</span><span class="token lambda 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 keyword" style="color:#00009f">if</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">null</span><span class="token plain"> z</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 keyword" style="color:#00009f">setq</span><span class="token plain"> x </span><span class="token number" style="color:#36acaa">0</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 car">+</span><span class="token plain"> x z</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</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"> funs</span><span class="token punctuation" style="color:#393A34">)</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"> funs</span><span class="token punctuation" style="color:#393A34">)</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>
<p>is also a <span><i>list</i></span> of ten <span><i>closures</i></span>. However, in this case no two of the <em>closure objects</em> can be <span><i>identical</i></span> because each <span><i>closure</i></span> is closed over a distinct <span><i>binding</i></span> of x, and these <span><i>bindings</i></span> can be behaviorally distinguished because of the use of <span><b>setq</b></span>.</p>
<p>The result of the <span><i>form</i></span></p>
<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 punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">let</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">funs</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</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 punctuation" style="color:#393A34">(</span><span class="token car">dotimes</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">j</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"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">let</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">x</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">5</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 punctuation" style="color:#393A34">(</span><span class="token car">push</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">function</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token lambda keyword" style="color:#00009f">lambda</span><span class="token lambda"> </span><span class="token lambda punctuation" style="color:#393A34">(</span><span class="token lambda arguments argument variable" style="color:#36acaa">z</span><span class="token lambda punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">+</span><span class="token plain"> x z</span><span class="token punctuation" style="color:#393A34">)</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"> funs</span><span class="token punctuation" style="color:#393A34">)</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"> funs</span><span class="token punctuation" style="color:#393A34">)</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>
<p>is a <span><i>list</i></span> of ten <em>closure objects</em> that might or might not be <span><i>identical</i></span>. A different <span><i>binding</i></span> of x is involved for each <span><i>closure</i></span>, but the <span><i>bindings</i></span> cannot be distinguished because their values are the <span><i>same</i></span> and immutable (there being no occurrence of <span><b>setq</b></span> on x). A compiler could internally transform the <span><i>form</i></span> to</p>
<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 punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">let</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">funs</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</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 punctuation" style="color:#393A34">(</span><span class="token car">dotimes</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">j</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"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">push</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">function</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token lambda keyword" style="color:#00009f">lambda</span><span class="token lambda"> </span><span class="token lambda punctuation" style="color:#393A34">(</span><span class="token lambda arguments argument variable" style="color:#36acaa">z</span><span class="token lambda punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">+</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">5</span><span class="token plain"> z</span><span class="token punctuation" style="color:#393A34">)</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"> funs</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"> funs</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>
<p>where the <span><i>closures</i></span> may be <span><i>identical</i></span>.</p>
<p>It is possible that a <span><i>closure</i></span> does not close over any variable bindings. In the code fragment (mapcar (function (lambda (x) (+ x 2))) y)</p>
<p>the function (lambda (x) (+ x 2)) contains no references to any outside object. In this case, the same <span><i>closure</i></span> might be returned for all evaluations of the <span><b>function</b></span> <span><i>form</i></span>.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="315-shadowing">3.1.5 Shadowing<a href="d-b-evaluation.html#315-shadowing" class="hash-link" aria-label="Direct link to 3.1.5 Shadowing" title="Direct link to 3.1.5 Shadowing"></a></h2>
<!-- -->
<p>If two <span><i>forms</i></span> that <em>establish lexical bindings</em> with the same <em>name N</em> are textually nested, then references to <em>N</em> within the inner <span><i>form</i></span> refer to the <span><i>binding</i></span> established by the inner <span><i>form</i></span>; the inner <span><i>binding</i></span> for <em>N shadows</em> the outer <span><i>binding</i></span> for <em>N</em>. Outside the inner <span><i>form</i></span> but inside the outer one, references to <em>N</em> refer to the <span><i>binding</i></span> established by the outer <span><i>form</i></span>. For example:</p>
<p>(defun test (x z)</p>
<p>(let ((z (* x 2)))</p>
<p>(print z))</p>
<p>z)</p>
<p>The <span><i>binding</i></span> of the variable z by <span><b>let</b></span> shadows the <span><i>parameter</i></span> binding for the function test. The reference to the variable z in the <span><b>print</b></span> <span><i>form</i></span> refers to the <span><b>let</b></span> binding. The reference to z at the end of the function test refers to the <span><i>parameter</i></span> named z.</p>
<p>Constructs that are lexically scoped act as if new names were generated for each <span><i>object</i></span> on each execution. Therefore, dynamic shadowing cannot occur. For example:</p>
<p>(defun contorted-example (f g x)</p>
<p>(if (= x 0)</p>
<p>(funcall f)</p>
<p>(block here</p>
<p>(+ 5 (contorted-example g</p>
<p>#(lambda () (return-from here 4))</p>
<p>(- x 1))))))</p>
<p>Consider the call (contorted-example nil nil 2). This produces 4. During the course of execution, there are three calls to contorted-example, interleaved with two blocks:</p>
<p>(contorted-example nil nil 2)</p>
<p>(block here<sub>1</sub> ...)</p>
<p>(contorted-example nil #(lambda () (return-from here<sub>1</sub> 4)) 1)</p>
<p>(block here<sub>2</sub> ...)</p>
<p>(contorted-example #(lambda () (return-from here<sub>1</sub> 4))</p>
<p>#(lambda () (return-from here<sub>2</sub> 4))</p>
<p>\0)</p>
<p>(funcall f)</p>
<p>where f → #(lambda () (return-from here<sub>1</sub> 4))</p>
<p>(return-from here<sub>1</sub> 4)</p>
<p>At the time the funcall is executed there are two <span><b>block</b></span> <span><i>exit points</i></span> outstanding, each apparently named here. The <span><b>return-from</b></span> <span><i>form</i></span> executed as a result of the funcall operation refers to the outer outstanding <span><i>exit point</i></span> (here<sub>1</sub>), not the inner one (here<sub>2</sub>). It refers to that <span><i>exit point</i></span> textually visible at the point of execution of <span><b>function</b></span> (here abbreviated by the # syntax) that resulted in creation of the <em>function object</em> actually invoked by <span><b>funcall</b></span>.</p>
<p>If, in this example, one were to change the (funcall f) to (funcall g), then the value of the call (contorted-example nil nil 2) would be 9. The value would change because <span><b>funcall</b></span> would cause the execution of (return-from here<sub>2</sub> 4), thereby causing a return from the inner <span><i>exit point</i></span> (here<sub>2</sub>).</p>
<p>When that occurs, the value 4 is returned from the middle invocation of contorted-example, 5 is added to that to get 9, and that value is returned from the outer block and the outermost call to contorted-example. The point is that the choice of <span><i>exit point</i></span> returned from has nothing to do with its being innermost or outermost; rather, it depends on the lexical environment that is packaged up with a <span><i>lambda expression</i></span> when <span><b>function</b></span> is executed.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="316-extent">3.1.6 Extent<a href="d-b-evaluation.html#316-extent" class="hash-link" aria-label="Direct link to 3.1.6 Extent" title="Direct link to 3.1.6 Extent"></a></h2>
<!-- -->
<p>Contorted-example works only because the <span><i>function</i></span> named by f is invoked during the <span><i>extent</i></span> of the <span><i>exit point</i></span>. Once the flow of execution has left the block, the <span><i>exit point</i></span> is <em>disestablished</em>. For example:</p>
<p>(defun invalid-example ()</p>
<p>(let ((y (block here #(lambda (z) (return-from here z)))))</p>
<p>(if (numberp y) y (funcall y 5))))</p>
<p>One might expect the call (invalid-example) to produce 5 by the following incorrect reasoning: <span><b>let</b></span> binds y to the value of <span><b>block</b></span>; this value is a <span><i>function</i></span> resulting from the <span><i>lambda expression</i></span>. Because y is not a number, it is invoked on the value 5. The <span><b>return-from</b></span> should then return this value from the <span><i>exit point</i></span> named here, thereby exiting from the block again and giving y the value 5 which, being a number, is then returned as the value of the call to invalid-example.</p>
<p>The argument fails only because <span><i>exit points</i></span> have <span><i>dynamic extent</i></span>. The argument is correct up to the execution of <span><b>return-from</b></span>. The execution of <span><b>return-from</b></span> should signal an error of <span><i>type</i></span> <span><b>control-error</b></span>, however, not because it cannot refer to the <span><i>exit point</i></span>, but because it does correctly refer to an <span><i>exit point</i></span> and that <span><i>exit point</i></span> has been <em>disestablished</em>.</p>
<p>A reference by name to a dynamic <span><i>exit point</i></span> binding such as a <span><i>catch tag</i></span> refers to the most recently <em>established binding</em> of that name that has not been <em>disestablished</em>. For example:</p>
<p>(defun fun1 (x)</p>
<p>(catch trap (+ 3 (fun2 x))))</p>
<p>(defun fun2 (y)</p>
<p>(catch trap (* 5 (fun3 y))))</p>
<p>(defun fun3 (z)</p>
<p>(throw trap z))</p>
<p>Consider the call (fun1 7). The result is 10. At the time the <span><b>throw</b></span> is executed, there are two outstanding catchers with the name trap: one established within procedure fun1, and the other within procedure fun2. The latter is the more recent, and so the value 7 is returned from <span><b>catch</b></span> in fun2. Viewed from within fun3, the <span><b>catch</b></span> in fun2 shadows the one in fun1. Had fun2 been defined as</p>
<p>(defun fun2 (y)</p>
<p>(catch snare (* 5 (fun3 y))))</p>
<p>then the two <span><i>exit points</i></span> would have different <span><i>names</i></span>, and therefore the one in fun1 would not be shadowed. The result would then have been 7.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="317-return-values">3.1.7 Return Values<a href="d-b-evaluation.html#317-return-values" class="hash-link" aria-label="Direct link to 3.1.7 Return Values" title="Direct link to 3.1.7 Return Values"></a></h2>
<!-- -->
<!-- -->
<p>Ordinarily the result of calling a <span><i>function</i></span> is a single <span><i>object</i></span>. Sometimes, however, it is convenient for a function to compute several <span><i>objects</i></span> and return them.</p>
<p>In order to receive other than exactly one value from a <span><i>form</i></span>, one of several <span><i>special forms</i></span> or <span><i>macros</i></span> must be used to request those values. If a <span><i>form</i></span> produces <span><i>multiple values</i></span> which were not requested in this way, then the first value is given to the caller and all others are discarded; if the <span><i>form</i></span> produces zero values, then the caller receives <span><b>nil</b></span> as a value.</p>
<p>Figure 35 lists some <span><i>operators</i></span> for receiving <span><i>multiple values</i></span><sub>2</sub>. These <span><i>operators</i></span> can be used to specify one or more <span><i>forms</i></span> to <span><i>evaluate</i></span> and where to put the <span><i>values</i></span> returned by those <span><i>forms</i></span>.</p>
<p>|</p><p><strong>multiple-value-bind multiple-value-prog1 return-from multiple-value-call multiple-value-setq throw</strong> </p><p><strong>multiple-value-list return</strong></p>|<p></p>
<p>| :- |</p>
<p><strong>Figure 35. Some operators applicable to receiving multiple values</strong></p>
<p>The <span><i>function</i></span> <span><b>values</b></span> can produce <span><i>multiple values</i></span><sub>2</sub>. (values) returns zero values; (values <span><i>form</i></span>) returns the <span><i>primary value</i></span> returned by <span><i>form</i></span>; (values <em>form1 form2</em>) returns two values, the <span><i>primary value</i></span> of <em>form1</em> and the <span><i>primary value</i></span> of <em>form2</em>; and so on.</p>
<p>See <span><b>multiple-values-limit</b></span> and <span><b>values-list</b></span>.</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-3/d-b-evaluation.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="../chap-2/c-e-standard-macro-characters.html"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">2.4 Standard Macro Characters</div></a><a class="pagination-nav__link pagination-nav__link--next" href="d-c-compilation.html"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">3.2 Compilation</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="d-b-evaluation.html#311-introduction-to-environments" class="table-of-contents__link toc-highlight">3.1.1 Introduction to Environments</a><ul><li><a href="d-b-evaluation.html#3111-the-global-environment" class="table-of-contents__link toc-highlight">3.1.1.1 The Global Environment</a></li><li><a href="d-b-evaluation.html#3112-dynamic-environments" class="table-of-contents__link toc-highlight">3.1.1.2 Dynamic Environments</a></li><li><a href="d-b-evaluation.html#3113-lexical-environments" class="table-of-contents__link toc-highlight">3.1.1.3 Lexical Environments</a><ul><li><a href="d-b-evaluation.html#31131-the-null-lexical-environment" class="table-of-contents__link toc-highlight">3.1.1.3.1 The Null Lexical Environment</a></li></ul></li><li><a href="d-b-evaluation.html#3114-environment-objects" class="table-of-contents__link toc-highlight">3.1.1.4 Environment Objects</a></li></ul></li><li><a href="d-b-evaluation.html#312-the-evaluation-model" class="table-of-contents__link toc-highlight">3.1.2 The Evaluation Model</a><ul><li><a href="d-b-evaluation.html#3121-form-evaluation" class="table-of-contents__link toc-highlight">3.1.2.1 Form Evaluation</a><ul><li><a href="d-b-evaluation.html#31211-symbols-as-forms" class="table-of-contents__link toc-highlight">3.1.2.1.1 Symbols as Forms</a><ul><li><a href="d-b-evaluation.html#312111-lexical-variables" class="table-of-contents__link toc-highlight">3.1.2.1.1.1 Lexical Variables</a></li><li><a href="d-b-evaluation.html#312112-dynamic-variables" class="table-of-contents__link toc-highlight">3.1.2.1.1.2 Dynamic Variables</a></li><li><a href="d-b-evaluation.html#312113-constant-variables" class="table-of-contents__link toc-highlight">3.1.2.1.1.3 Constant Variables</a></li><li><a href="d-b-evaluation.html#312114-symbols-naming-both-lexical-and-dynamic-variables" class="table-of-contents__link toc-highlight">3.1.2.1.1.4 Symbols Naming Both Lexical and Dynamic Variables</a></li></ul></li><li><a href="d-b-evaluation.html#31212-conses-as-forms" class="table-of-contents__link toc-highlight">3.1.2.1.2 Conses as Forms</a><ul><li><a href="d-b-evaluation.html#312121-special-forms" class="table-of-contents__link toc-highlight">3.1.2.1.2.1 Special Forms</a></li><li><a href="d-b-evaluation.html#312122-macro-forms" class="table-of-contents__link toc-highlight">3.1.2.1.2.2 Macro Forms</a></li><li><a href="d-b-evaluation.html#312123-function-forms" class="table-of-contents__link toc-highlight">3.1.2.1.2.3 Function Forms</a></li><li><a href="d-b-evaluation.html#312124-lambda-forms" class="table-of-contents__link toc-highlight">3.1.2.1.2.4 Lambda Forms</a></li></ul></li><li><a href="d-b-evaluation.html#31213-self" class="table-of-contents__link toc-highlight">3.1.2.1.3 Self</a><ul><li><a href="d-b-evaluation.html#312131-examples-of-self" class="table-of-contents__link toc-highlight">3.1.2.1.3.1 Examples of Self</a></li></ul></li></ul></li></ul></li><li><a href="d-b-evaluation.html#313-lambda-expressions" class="table-of-contents__link toc-highlight">3.1.3 Lambda Expressions</a></li><li><a href="d-b-evaluation.html#314-closures-and-lexical-binding" class="table-of-contents__link toc-highlight">3.1.4 Closures and Lexical Binding</a></li><li><a href="d-b-evaluation.html#315-shadowing" class="table-of-contents__link toc-highlight">3.1.5 Shadowing</a></li><li><a href="d-b-evaluation.html#316-extent" class="table-of-contents__link toc-highlight">3.1.6 Extent</a></li><li><a href="d-b-evaluation.html#317-return-values" class="table-of-contents__link toc-highlight">3.1.7 Return Values</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>