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

253 lines
No EOL
91 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-c-compilation" data-has-hydrated="false">
<head>
<meta charset="UTF-8">
<meta name="generator" content="Docusaurus v3.0.1">
<title data-rh="true">3.2 Compilation | 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-c-compilation"><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.2 Compilation | Common Lisp (New) Language Reference"><meta data-rh="true" name="description" content="3.2.1 Compiler Terminology"><meta data-rh="true" property="og:description" content="3.2.1 Compiler Terminology"><link data-rh="true" rel="icon" href="../img/favicon.ico"><link data-rh="true" rel="canonical" href="d-c-compilation.html"><link data-rh="true" rel="alternate" href="d-c-compilation.html" hreflang="en"><link data-rh="true" rel="alternate" href="d-c-compilation.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-c-compilation.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" 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 menu__link--active" aria-current="page" 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.2 Compilation</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.2 Compilation</h1>
<!-- -->
<!-- -->
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="321-compiler-terminology">3.2.1 Compiler Terminology<a href="d-c-compilation.html#321-compiler-terminology" class="hash-link" aria-label="Direct link to 3.2.1 Compiler Terminology" title="Direct link to 3.2.1 Compiler Terminology"></a></h2>
<!-- -->
<p>The following terminology is used in this section.</p>
<p>The <span><i>compiler</i></span> is a utility that translates code into an <span><i>implementation-dependent</i></span> form that might be represented or executed efficiently. The term <span><i>compiler</i></span> refers to both of the <span><i>functions</i></span> <span><b>compile</b></span> and <span><b>compile-file</b></span>.</p>
<p>The term <span><i>compiled code</i></span> refers to <span><i>objects</i></span> representing compiled programs, such as <span><i>objects</i></span> constructed by <span><b>compile</b></span> or by <span><b>load</b></span> when <em>loading</em> a <span><i>compiled file</i></span>.</p>
<p>The term <span><i>implicit compilation</i></span> refers to <span><i>compilation</i></span> performed during <span><i>evaluation</i></span>.</p>
<p>The term <em>literal object</em> refers to a quoted <span><i>object</i></span> or a <span><i>self-evaluating object</i></span> or an <span><i>object</i></span> that is a substructure of such an <span><i>object</i></span>. A <span><i>constant variable</i></span> is not itself a <em>literal object</em>.</p>
<p>The term <span><i>coalesce</i></span> is defined as follows. Suppose A and B are two <em>literal constants</em> in the <span><i>source code</i></span>, and that A and B are the corresponding <span><i>objects</i></span> in the <span><i>compiled code</i></span>. If A and B are <span><b>eql</b></span> but A and B are not <span><b>eql</b></span>, then it is said that A and B have been coalesced by the compiler.</p>
<p>The term <span><i>minimal compilation</i></span> refers to actions the compiler must take at <span><i>compile time</i></span>. These actions are specified in Section 3.2.2 (Compilation Semantics).</p>
<p>The verb <span><i>process</i></span> refers to performing <span><i>minimal compilation</i></span>, determining the time of evaluation for a <span><i>form</i></span>, and possibly <em>evaluating</em> that <span><i>form</i></span> (if required).</p>
<p>The term <span><i>further compilation</i></span> refers to <span><i>implementation-dependent</i></span> compilation beyond <span><i>minimal compilation</i></span>. That is, <em>processing</em> does not imply complete compilation. Block compilation and generation of machine-specific instructions are examples of further compilation. Further compilation is permitted to take place at <span><i>run time</i></span>.</p>
<p>Four different <span><i>environments</i></span> relevant to compilation are distinguished: the <span><i>startup environment</i></span>, the <span><i>compilation environment</i></span>, the <span><i>evaluation environment</i></span>, and the <span><i>run-time environment</i></span>.</p>
<p>The <span><i>startup environment</i></span> is the <span><i>environment</i></span> of the <em>Lisp image</em> from which the <span><i>compiler</i></span> was invoked.</p>
<p>The <span><i>compilation environment</i></span> is maintained by the compiler and is used to hold definitions and declarations to be used internally by the compiler. Only those parts of a definition needed for correct compilation are saved. The <span><i>compilation environment</i></span> is used as the <em>environment argument</em> to macro expanders called by the compiler. It is unspecified whether a definition available in the <span><i>compilation environment</i></span> can be used in an <span><i>evaluation</i></span> initiated in the <span><i>startup environment</i></span> or <span><i>evaluation environment</i></span>.</p>
<p>The <span><i>evaluation environment</i></span> is a <span><i>run-time environment</i></span> in which macro expanders and code specified by <span><b>eval-when</b></span> to be evaluated are evaluated. All evaluations initiated by the <span><i>compiler</i></span></p>
<p>take place in the <span><i>evaluation environment</i></span>.</p>
<p>The <span><i>run-time environment</i></span> is the <span><i>environment</i></span> in which the program being compiled will be executed.</p>
<p>The <span><i>compilation environment</i></span> inherits from the <span><i>evaluation environment</i></span>, and the <span><i>compilation environment</i></span> and <span><i>evaluation environment</i></span> might be <span><i>identical</i></span>. The <span><i>evaluation environment</i></span> inherits from the <span><i>startup environment</i></span>, and the <span><i>startup environment</i></span> and <span><i>evaluation environment</i></span> might be <span><i>identical</i></span>.</p>
<p>The term <span><i>compile time</i></span> refers to the duration of time that the compiler is processing <span><i>source code</i></span>. At <span><i>compile time</i></span>, only the <span><i>compilation environment</i></span> and the <span><i>evaluation environment</i></span> are available.</p>
<p>The term <em>compile-time definition</em> refers to a definition in the <span><i>compilation environment</i></span>. For example, when compiling a file, the definition of a function might be retained in the <span><i>compilation environment</i></span> if it is declared <span><b>inline</b></span>. This definition might not be available in the <span><i>evaluation environment</i></span>.</p>
<p>The term <span><i>run time</i></span> refers to the duration of time that the loader is loading compiled code or compiled code is being executed. At run time, only the <span><i>run-time environment</i></span> is available.</p>
<p>The term <span><i>run-time definition</i></span> refers to a definition in the <span><i>run-time environment</i></span>.</p>
<p>The term <span><i>run-time compiler</i></span> refers to the <span><i>function</i></span> <span><b>compile</b></span> or <span><i>implicit compilation</i></span>, for which the compilation and run-time <span><i>environments</i></span> are maintained in the same <em>Lisp image</em>. Note that when the <span><i>run-time compiler</i></span> is used, the <span><i>run-time environment</i></span> and <span><i>startup environment</i></span> are the same.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="322-compilation-semantics">3.2.2 Compilation Semantics<a href="d-c-compilation.html#322-compilation-semantics" class="hash-link" aria-label="Direct link to 3.2.2 Compilation Semantics" title="Direct link to 3.2.2 Compilation Semantics"></a></h2>
<!-- -->
<p>Conceptually, compilation is a process that traverses code, performs certain kinds of syntactic and semantic analyses using information (such as proclamations and <span><i>macro</i></span> definitions) present in the <span><i>compilation environment</i></span>, and produces equivalent, possibly more efficient code.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="3221-compiler-macros">3.2.2.1 Compiler Macros<a href="d-c-compilation.html#3221-compiler-macros" class="hash-link" aria-label="Direct link to 3.2.2.1 Compiler Macros" title="Direct link to 3.2.2.1 Compiler Macros"></a></h3>
<!-- -->
<p>A <span><i>compiler macro</i></span> can be defined for a <span><i>name</i></span> that also names a <span><i>function</i></span> or <span><i>macro</i></span>. That is, it is possible for a <span><i>function name</i></span> to name both a <span><i>function</i></span> and a <span><i>compiler macro</i></span>.</p>
<p>A <span><i>function name</i></span> names a <span><i>compiler macro</i></span> if <span><b>compiler-macro-function</b></span> is <span><i>true</i></span> of the <span><i>function name</i></span> in the <span><i>lexical environment</i></span> in which it appears. Creating a <span><i>lexical binding</i></span> for the <span><i>function name</i></span> not only creates a new local <span><i>function</i></span> or <span><i>macro</i></span> definition, but also <span><i>shadows</i></span><sub>2</sub> the <span><i>compiler macro</i></span>.</p>
<p>The <span><i>function</i></span> returned by <span><b>compiler-macro-function</b></span> is a <span><i>function</i></span> of two arguments, called the expansion function. To expand a <span><i>compiler macro</i></span>, the expansion function is invoked by calling the <span><i>macroexpand hook</i></span> with the expansion function as its first argument, the entire compiler macro <span><i>form</i></span> as its second argument, and the current compilation <span><i>environment</i></span> (or with the current lexical <span><i>environment</i></span>, if the <span><i>form</i></span> is being processed by something other than <span><b>compile-file</b></span>) as its third</p>
<p>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 return value from the expansion function, which is passed through by the <span><i>macroexpand hook</i></span>, might either be the <em>same form</em>, or else a form that can, at the discretion of the <span><i>code</i></span> doing the expansion, be used in place of the original <span><i>form</i></span>.</p>
<p>|<strong>*macroexpand-hook* compiler-macro-function define-compiler-macro</strong>|</p>
<p>| :- |</p>
<p><strong>Figure 36. Defined names applicable to compiler macros</strong></p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="32211-purpose-of-compiler-macros">3.2.2.1.1 Purpose of Compiler Macros<a href="d-c-compilation.html#32211-purpose-of-compiler-macros" class="hash-link" aria-label="Direct link to 3.2.2.1.1 Purpose of Compiler Macros" title="Direct link to 3.2.2.1.1 Purpose of Compiler Macros"></a></h4>
<!-- -->
<p>The purpose of the <span><i>compiler macro</i></span> facility is to permit selective source code transformations as optimization advice to the <span><i>compiler</i></span> . When a <span><i>compound form</i></span> is being processed (as by the compiler), if the <span><i>operator</i></span> names a <span><i>compiler macro</i></span> then the <span><i>compiler macro function</i></span> may be</p>
<p>invoked on the form, and the resulting expansion recursively processed in preference to performing the usual processing on the original <span><i>form</i></span> according to its normal interpretation as a <span><i>function form</i></span> or <span><i>macro form</i></span>.</p>
<p>A <span><i>compiler macro function</i></span>, like a <span><i>macro function</i></span>, is a <span><i>function</i></span> of two <span><i>arguments</i></span>: the entire call <span><i>form</i></span> and the <span><i>environment</i></span>. Unlike an ordinary <span><i>macro function</i></span>, a <span><i>compiler macro function</i></span> can decline to provide an expansion merely by returning a value that is the <span><i>same</i></span> as the original <span><i>form</i></span>. The consequences are undefined if a <span><i>compiler macro function</i></span> destructively modifies any part of its <span><i>form</i></span> argument.</p>
<p>The <span><i>form</i></span> passed to the compiler macro function can either be a <span><i>list</i></span> whose <span><i>car</i></span> is the function name, or a <span><i>list</i></span> whose <span><i>car</i></span> is <span><b>funcall</b></span> and whose <span><i>cadr</i></span> is a list (function <span><i>name</i></span>); note that this affects destructuring of the form argument by the <span><i>compiler macro function</i></span>. <span><b>define-compiler-macro</b></span> arranges for destructuring of arguments to be performed correctly for both possible formats.</p>
<p>When <span><b>compile-file</b></span> chooses to expand a <span><i>top level form</i></span> that is a <span><i>compiler macro form</i></span>, the expansion is also treated as a <span><i>top level form</i></span> for the purposes of <span><b>eval-when</b></span> processing; see Section 3.2.3.1 (Processing of Top Level Forms).</p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="32212-naming-of-compiler-macros">3.2.2.1.2 Naming of Compiler Macros<a href="d-c-compilation.html#32212-naming-of-compiler-macros" class="hash-link" aria-label="Direct link to 3.2.2.1.2 Naming of Compiler Macros" title="Direct link to 3.2.2.1.2 Naming of Compiler Macros"></a></h4>
<!-- -->
<p><span><i>Compiler macros</i></span> may be defined for <span><i>function names</i></span> that name <span><i>macros</i></span> as well as <span><i>functions</i></span>.</p>
<p><span><i>Compiler macro</i></span> definitions are strictly global. There is no provision for defining local <span><i>compiler macros</i></span> in the way that <span><b>macrolet</b></span> defines local <span><i>macros</i></span>. Lexical bindings of a function name shadow any compiler macro definition associated with the name as well as its global <span><i>function</i></span> or <span><i>macro</i></span> definition.</p>
<p>Note that the presence of a compiler macro definition does not affect the values returned by functions that access <span><i>function</i></span> definitions (<em>e.g.</em>, <span><b>fboundp</b></span>) or <span><i>macro</i></span> definitions (<em>e.g.</em>, <span><b>macroexpand</b></span>).</p>
<p>Compiler macros are global, and the function <span><b>compiler-macro-function</b></span> is sufficient to resolve their interaction with other lexical and global definitions.</p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="32213-when-compiler-macros-are-used">3.2.2.1.3 When Compiler Macros Are Used<a href="d-c-compilation.html#32213-when-compiler-macros-are-used" class="hash-link" aria-label="Direct link to 3.2.2.1.3 When Compiler Macros Are Used" title="Direct link to 3.2.2.1.3 When Compiler Macros Are Used"></a></h4>
<!-- -->
<p>The presence of a <span><i>compiler macro</i></span> definition for a <span><i>function</i></span> or <span><i>macro</i></span> indicates that it is desirable for the <span><i>compiler</i></span> to use the expansion of the <span><i>compiler macro</i></span> instead of the original <span><i>function form</i></span> or <span><i>macro form</i></span>. However, no language processor (compiler, evaluator, or other code walker) is ever required to actually invoke <span><i>compiler macro functions</i></span>, or to make use of the resulting expansion if it does invoke a <span><i>compiler macro function</i></span>.</p>
<p>When the <span><i>compiler</i></span> encounters a <span><i>form</i></span> during processing that represents a call to a <em>compiler macro name</em> (that is not declared <span><b>notinline</b></span>), the <span><i>compiler</i></span> might expand the <span><i>compiler macro</i></span>, and might use the expansion in place of the original <span><i>form</i></span>.</p>
<p>When <span><b>eval</b></span> encounters a <span><i>form</i></span> during processing that represents a call to a <em>compiler macro name</em> (that is not declared <span><b>notinline</b></span>), <span><b>eval</b></span> might expand the <span><i>compiler macro</i></span>, and might use the expansion in place of the original <span><i>form</i></span>.</p>
<p>There are two situations in which a <span><i>compiler macro</i></span> definition must not be applied by any language processor:</p>
<p><em></em> The global function name binding associated with the compiler macro is shadowed by a lexical binding of the function name.</p>
<p><em></em> The function name has been declared or proclaimed <span><b>notinline</b></span> and the call form appears within the scope of the declaration.</p>
<p>It is unspecified whether <span><i>compiler macros</i></span> are expanded or used in any other situations.</p>
<h5 class="anchor anchorWithStickyNavbar_LWe7" id="322131-notes-about-the-implementation-of-compiler-macros">3.2.2.1.3.1 Notes about the Implementation of Compiler Macros<a href="d-c-compilation.html#322131-notes-about-the-implementation-of-compiler-macros" class="hash-link" aria-label="Direct link to 3.2.2.1.3.1 Notes about the Implementation of Compiler Macros" title="Direct link to 3.2.2.1.3.1 Notes about the Implementation of Compiler Macros"></a></h5>
<!-- -->
<p>Although it is technically permissible, as described above, for <span><b>eval</b></span> to treat <span><i>compiler macros</i></span> in the same situations as <span><i>compiler</i></span> might, this is not necessarily a good idea in <span><i>interpreted implementations</i></span>.</p>
<p><span><i>Compiler macros</i></span> exist for the purpose of trading compile-time speed for run-time speed. Programmers who write <span><i>compiler macros</i></span> tend to assume that the <span><i>compiler macros</i></span> can take more time than normal <span><i>functions</i></span> and <span><i>macros</i></span> in order to produce code which is especially optimal for use at run time. Since <span><b>eval</b></span> in an <span><i>interpreted implementation</i></span> might perform semantic analysis of the same form multiple times, it might be inefficient in general for the <span><i>implementation</i></span> to choose to call <span><i>compiler macros</i></span> on every such <span><i>evaluation</i></span>.</p>
<p>Nevertheless, the decision about what to do in these situations is left to each <span><i>implementation</i></span>. Evaluation and</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="3222-minimal-compilation">3.2.2.2 Minimal Compilation<a href="d-c-compilation.html#3222-minimal-compilation" class="hash-link" aria-label="Direct link to 3.2.2.2 Minimal Compilation" title="Direct link to 3.2.2.2 Minimal Compilation"></a></h3>
<!-- -->
<p><span><i>Minimal compilation</i></span> is defined as follows:</p>
<p><em></em> All <span><i>compiler macro</i></span> calls appearing in the <span><i>source code</i></span> being compiled are expanded, if at all, at compile time; they will not be expanded at run time.</p>
<p><em></em> All <span><i>macro</i></span> and <span><i>symbol macro</i></span> calls appearing in the source code being compiled are expanded at compile time in such a way that they will not be expanded again at run time. <span><b>macrolet</b></span> and <span><b>symbol-macrolet</b></span> are effectively replaced by <span><i>forms</i></span> corresponding to their bodies in which calls to <span><i>macros</i></span> are replaced by their expansions.</p>
<p><em></em> The first <span><i>argument</i></span> in a <span><b>load-time-value</b></span> <span><i>form</i></span> in <span><i>source code</i></span> processed by <span><b>compile</b></span> is <em>evaluated</em> at <span><i>compile time</i></span>; in <span><i>source code</i></span> processed by <span><b>compile-file</b></span>, the compiler arranges for it to be <em>evaluated</em> at <span><i>load time</i></span>. In either case, the result of the <span><i>evaluation</i></span> is remembered and used later as the value of the <span><b>load-time-value</b></span> <span><i>form</i></span> at <em>execution time</em>.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="3223-semantic-constraints">3.2.2.3 Semantic Constraints<a href="d-c-compilation.html#3223-semantic-constraints" class="hash-link" aria-label="Direct link to 3.2.2.3 Semantic Constraints" title="Direct link to 3.2.2.3 Semantic Constraints"></a></h3>
<!-- -->
<p>All <span><i>conforming programs</i></span> must obey the following constraints, which are designed to minimize the observable differences between compiled and interpreted programs:</p>
<p><em></em> Definitions of any referenced <span><i>macros</i></span> must be present in the <span><i>compilation environment</i></span>. Any <span><i>form</i></span> that is a <span><i>list</i></span> beginning with a <span><i>symbol</i></span> that does not name a <span><i>special operator</i></span> or a <span><i>macro</i></span> defined in the <span><i>compilation environment</i></span> is treated by the compiler as a function call.</p>
<p><em></em> <strong>Special</strong> proclamations for <span><i>dynamic variables</i></span> must be made in the <span><i>compilation environment</i></span>. Any <span><i>binding</i></span> for which there is no <span><b>special</b></span> declaration or proclamation in the <span><i>compilation environment</i></span> is treated by the compiler as a <span><i>lexical binding</i></span>.</p>
<p><em></em> The definition of a function that is defined and declared <span><b>inline</b></span> in the <span><i>compilation environment</i></span> must be the same at run time.</p>
<p><em></em> Within a <span><i>function</i></span> named <em>F</em>, the compiler may (but is not required to) assume that an apparent recursive call to a <span><i>function</i></span> named <em>F</em> refers to the same definition of <em>F</em>, unless that function has been declared <span><b>notinline</b></span>. The consequences of redefining such a recursively defined <em>function F</em> while it is executing are undefined.</p>
<p><em></em> A call within a file to a named function that is defined in the same file refers to that function, unless that function has been declared <span><b>notinline</b></span>. The consequences are unspecified if functions are redefined individually at run time or multiply defined in the same file.</p>
<p><em></em> The argument syntax and number of return values for all functions whose <span><b>ftype</b></span> is declared at compile time must remain the same at run time.</p>
<p><em>• Constant variables</em> defined in the <span><i>compilation environment</i></span> must have a <span><i>similar</i></span> value at run time. A reference to a <span><i>constant variable</i></span> in <span><i>source code</i></span> is equivalent to a reference to a <em>literal object</em> that is the <span><i>value</i></span> of the <span><i>constant variable</i></span>.</p>
<p><em></em> Type definitions made with <span><b>deftype</b></span> or <span><b>defstruct</b></span> in the <span><i>compilation environment</i></span> must retain the same definition at run time. Classes defined by <span><b>defclass</b></span> in the <span><i>compilation environment</i></span> must be defined at run time to have the same <em>superclasses</em> and same <span><i>metaclass</i></span>.</p>
<p>This implies that <span><i>subtype</i></span>/<span><i>supertype</i></span> relationships of <span><i>type specifiers</i></span> must not change between <span><i>compile time</i></span> and <span><i>run time</i></span>.</p>
<p><em></em> Type declarations present in the compilation <span><i>environment</i></span> must accurately describe the corresponding values at run time; otherwise, the consequences are undefined. It is permissible for an unknown <span><i>type</i></span> to appear in a declaration at compile time, though a warning might be signaled in such a case.</p>
<p><em></em> Except in the situations explicitly listed above, a <span><i>function</i></span> defined in the <span><i>evaluation environment</i></span> is permitted to have a different definition or a different <span><i>signature</i></span> at run time, and the run-time definition prevails.</p>
<p><span><i>Conforming programs</i></span> should not be written using any additional assumptions about consistency between the run-time <span><i>environment</i></span> and the startup, evaluation, and compilation <span><i>environments</i></span>.</p>
<p>Except where noted, when a compile-time and a run-time definition are different, one of the following occurs at run time:</p>
<p><em></em> an error of <span><i>type</i></span> <span><b>error</b></span> is signaled</p>
<p><em></em> the compile-time definition prevails</p>
<p><em></em> the run-time definition prevails</p>
<p>If the <span><i>compiler</i></span> processes a <span><i>function form</i></span> whose <span><i>operator</i></span> is not defined at compile time, no error is signaled at compile time.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="323-file-compilation">3.2.3 File Compilation<a href="d-c-compilation.html#323-file-compilation" class="hash-link" aria-label="Direct link to 3.2.3 File Compilation" title="Direct link to 3.2.3 File Compilation"></a></h2>
<!-- -->
<p>The <span><i>function</i></span> <span><b>compile-file</b></span> performs compilation of <span><i>forms</i></span> in a file following the rules specified in Section 3.2.2 (Compilation Semantics), and produces an output file that can be loaded by using <span><b>load</b></span>.</p>
<p>Normally, the <span><i>top level forms</i></span> appearing in a file compiled with <span><b>compile-file</b></span> are evaluated only when the resulting compiled file is loaded, and not when the file is compiled. However, it is typically the case that some forms in the file need to be evaluated at compile time so the remainder of the file can be read and compiled correctly.</p>
<p>The <span><b>eval-when</b></span> <span><i>special form</i></span> can be used to control whether a <span><i>top level form</i></span> is evaluated at compile time, load time, or both. It is possible to specify any of three situations with <span><b>eval-when</b></span>, denoted by the symbols <!-- -->:compile-toplevel<!-- -->, <!-- -->:load-toplevel<!-- -->, and <!-- -->:execute<!-- -->. For top level <span><b>eval-when</b></span> forms, <!-- -->:compile-toplevel<!-- --> specifies that the compiler must evaluate the body at compile time, and <!-- -->:load-toplevel<!-- --> specifies that the compiler must arrange to evaluate the body at load time. For non-top level <span><b>eval-when</b></span> forms, <!-- -->:execute<!-- --> specifies that the body must be executed in the run-time <span><i>environment</i></span>.</p>
<p>The behavior of this <span><i>form</i></span> can be more precisely understood in terms of a model of how <span><b>compile-file</b></span> processes forms in a file to be compiled. There are two processing modes, called “not-compile-time” and “compile-time-too”.</p>
<p>Successive forms are read from the file by <span><b>compile-file</b></span> and processed in not-compile-time mode; in this mode, <span><b>compile-file</b></span> arranges for forms to be evaluated only at load time and not at compile time. When <span><b>compile-file</b></span> is in compile-time-too mode, forms are evaluated both at compile time and load time.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="3231-processing-of-top-level-forms">3.2.3.1 Processing of Top Level Forms<a href="d-c-compilation.html#3231-processing-of-top-level-forms" class="hash-link" aria-label="Direct link to 3.2.3.1 Processing of Top Level Forms" title="Direct link to 3.2.3.1 Processing of Top Level Forms"></a></h3>
<!-- -->
<p>Processing of <span><i>top level forms</i></span> in the file compiler is defined as follows:</p>
<p>1. If the <span><i>form</i></span> is a <span><i>compiler macro form</i></span> (not disabled by a <span><b>notinline</b></span> <span><i>declaration</i></span>), the <span><i>implementation</i></span> might or might not choose to compute the <span><i>compiler macro expansion</i></span> of the <span><i>form</i></span> and, having performed the expansion, might or might not choose to process the result as a <span><i>top level form</i></span> in the same processing mode (compile-time-too or not-compile time). If it declines to obtain or use the expansion, it must process the original <span><i>form</i></span>.</p>
<p>2. If the form is a <span><i>macro form</i></span>, its <span><i>macro expansion</i></span> is computed and processed as a <span><i>top level form</i></span> in the same processing mode (compile-time-too or not-compile-time).</p>
<p>3. If the form is a <span><b>progn</b></span> form, each of its body <span><i>forms</i></span> is sequentially processed as a <span><i>top level form</i></span> in the same processing mode.</p>
<p>4. If the form is a <span><b>locally</b></span>, <span><b>macrolet</b></span>, or <span><b>symbol-macrolet</b></span>, <span><b>compile-file</b></span> establishes the appropriate bindings and processes the body forms as <span><i>top level forms</i></span> with those bindings in effect in the same processing mode. (Note that this implies that the lexical <span><i>environment</i></span> in which <span><i>top level forms</i></span> are processed is not necessarily the <span><i>null lexical environment</i></span>.)</p>
<p>5. If the form is an <span><b>eval-when</b></span> form, it is handled according to Figure 37.</p>
<p>|<strong>CT LT E Mode Action New Mode</strong>|</p>
<p>| :- |</p>
<p>|</p><p>Yes Yes — — Process compile-time-too No Yes Yes CTT Process compile-time-too No Yes Yes NCT Process not-compile-time No Yes No — Process not-compile-time Yes No — — Evaluate — </p><p>No No Yes CTT Evaluate — No No Yes NCT Discard — No No No — Discard —</p>|<p></p>
<p><strong>Figure 37. EVAL-WHEN processing</strong></p>
<p>Column <strong>CT</strong> indicates whether <!-- -->:compile-toplevel<!-- --> is specified. Column <strong>LT</strong> indicates whether <!-- -->:load-toplevel<!-- --> is specified. Column <strong>E</strong> indicates whether <!-- -->:execute<!-- --> is specified. Column <strong>Mode</strong> indicates the processing mode; a dash (—) indicates that the processing mode is not relevant.</p>
<p>The
<strong>Action</strong>
column specifies one of three actions:</p>
<p><strong>Process:</strong> process the body as <span><i>top level forms</i></span> in the specified mode.</p>
<p><strong>Evaluate:</strong> evaluate the body in the dynamic execution context of the compiler, using the <span><i>evaluation environment</i></span> as the global environment and the <span><i>lexical environment</i></span> in which the <span><b>eval-when</b></span> appears.</p>
<p><strong>Discard:</strong> ignore the <span><i>form</i></span>.</p>
<p>The <strong>New Mode</strong> column indicates the new processing mode. A dash (—) indicates the compiler remains in its current mode.</p>
<p>6. Otherwise, the form is a <span><i>top level form</i></span> that is not one of the special cases. In compile time-too mode, the compiler first evaluates the form in the evaluation <span><i>environment</i></span> and then minimally compiles it. In not-compile-time mode, the <span><i>form</i></span> is simply minimally compiled. All <span><i>subforms</i></span> are treated as <span><i>non-top-level forms</i></span>.</p>
<p>Note that <span><i>top level forms</i></span> are processed in the order in which they textually appear in the file and that each <span><i>top level form</i></span> read by the compiler is processed before the next is read. However, the order of processing (including macro expansion) of <span><i>subforms</i></span> that are not <span><i>top level forms</i></span> and the order of further compilation is unspecified as long as Common Lisp</p>
<p>semantics are preserved.</p>
<p><span><b>eval-when</b></span> forms cause compile-time evaluation only at top level. Both <!-- -->:compile-toplevel<!-- --> and <!-- -->:load-toplevel<!-- --> situation specifications are ignored for <span><i>non-top-level forms</i></span>. For <em>non-top-level</em></p>
<p><span><i>forms</i></span>, an <span><b>eval-when</b></span> specifying the <!-- -->:execute<!-- --> situation is treated as an <span><i>implicit progn</i></span> including the <span><i>forms</i></span> in the body of the <span><b>eval-when</b></span> <span><i>form</i></span>; otherwise, the <span><i>forms</i></span> in the body are ignored.</p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="32311-processing-of-defining-macros">3.2.3.1.1 Processing of Defining Macros<a href="d-c-compilation.html#32311-processing-of-defining-macros" class="hash-link" aria-label="Direct link to 3.2.3.1.1 Processing of Defining Macros" title="Direct link to 3.2.3.1.1 Processing of Defining Macros"></a></h4>
<!-- -->
<p>Defining <span><i>macros</i></span> (such as <span><b>defmacro</b></span> or <span><b>defvar</b></span>) appearing within a file being processed by <span><b>compile-file</b></span> normally have compile-time side effects which affect how subsequent <span><i>forms</i></span> in the same <span><i>file</i></span> are compiled. A convenient model for explaining how these side effects happen is that the defining macro expands into one or more <span><b>eval-when</b></span> <span><i>forms</i></span>, and that the calls which cause the compile-time side effects to happen appear in the body of an (eval-when (<!-- -->:compile-toplevel<!-- -->) ...) <span><i>form</i></span>.</p>
<p>The compile-time side effects may cause information about the definition to be stored differently than if the defining macro had been processed in the normal way (either interpretively or by loading the compiled file).</p>
<p>In particular, the information stored by the defining <span><i>macros</i></span> at compile time might or might not be available to the interpreter (either during or after compilation), or during subsequent calls to the <span><i>compiler</i></span> . For example, the following code is nonportable because it assumes that the <span><i>compiler</i></span> stores the macro definition of foo where it is available to the interpreter:</p>
<p>(defmacro foo (x) (car ,x))</p>
<p>(eval-when (<!-- -->:execute<!-- --> <!-- -->:compile-toplevel<!-- --> <!-- -->:load-toplevel<!-- -->)</p>
<p>(print (foo (a b c))))</p>
<p>A portable way to do the same thing would be to include the macro definition inside the <span><b>eval-when</b></span> <span><i>form</i></span>, as in:</p>
<p>(eval-when (<!-- -->:execute<!-- --> <!-- -->:compile-toplevel<!-- --> <!-- -->:load-toplevel<!-- -->)</p>
<p>(defmacro foo (x) (car ,x))</p>
<p>(print (foo (a b c))))</p>
<p>Figure 38 lists macros that make definitions available both in the compilation and run-time <span><i>environments</i></span>. It is not specified whether definitions made available in the <span><i>compilation environment</i></span> are available in the evaluation <span><i>environment</i></span>, nor is it specified whether they are available in subsequent compilation units or subsequent invocations of the compiler. As with <span><b>eval-when</b></span>, these compile-time side effects happen only when the defining macros appear at top level.</p>
<p>|<strong>declaim define-modify-macro defsetf defclass define-setf-expander defstruct defconstant defmacro deftype define-compiler-macro defpackage defvar define-condition defparameter</strong>|</p>
<p>| :- |</p>
<p><strong>Figure 38. Defining Macros That Affect the Compile-Time Environment</strong></p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="32312-constraints-on-macros-and-compiler-macros">3.2.3.1.2 Constraints on Macros and Compiler Macros<a href="d-c-compilation.html#32312-constraints-on-macros-and-compiler-macros" class="hash-link" aria-label="Direct link to 3.2.3.1.2 Constraints on Macros and Compiler Macros" title="Direct link to 3.2.3.1.2 Constraints on Macros and Compiler Macros"></a></h4>
<!-- -->
<p>Except where explicitly stated otherwise, no <span><i>macro</i></span> defined in the Common Lisp standard produces an expansion that could cause any of the <span><i>subforms</i></span> of the <span><i>macro form</i></span> to be treated as <span><i>top level forms</i></span>. If an <span><i>implementation</i></span> also provides a <span><i>special operator</i></span> definition of a Common Lisp <span><i>macro</i></span>, the <span><i>special operator</i></span> definition must be semantically equivalent in this respect.</p>
<p><span><i>Compiler macro</i></span> expansions must also have the same top level evaluation semantics as the <span><i>form</i></span> which they replace. This is of concern both to <span><i>conforming implementations</i></span> and to <span><i>conforming programs</i></span>.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="324-literal-objects-in-compiled-files">3.2.4 Literal Objects in Compiled Files<a href="d-c-compilation.html#324-literal-objects-in-compiled-files" class="hash-link" aria-label="Direct link to 3.2.4 Literal Objects in Compiled Files" title="Direct link to 3.2.4 Literal Objects in Compiled Files"></a></h2>
<!-- -->
<p>The functions <span><b>eval</b></span> and <span><b>compile</b></span> are required to ensure that <em>literal objects</em> referenced within the resulting interpreted or compiled code objects are the <span><i>same</i></span> as the corresponding <span><i>objects</i></span> in the <span><i>source code</i></span>. <span><b>compile-file</b></span>, on the other hand, must produce a <span><i>compiled file</i></span> that, when loaded with <span><b>load</b></span>, constructs the <span><i>objects</i></span> defined by the <span><i>source code</i></span> and produces references to them.</p>
<p>In the case of <span><b>compile-file</b></span>, <span><i>objects</i></span> constructed by <span><b>load</b></span> of the <span><i>compiled file</i></span> cannot be spoken of as being the <span><i>same</i></span> as the <span><i>objects</i></span> constructed at compile time, because the <span><i>compiled file</i></span> may be loaded into a different <em>Lisp image</em> than the one in which it was compiled. This section defines the concept of <span><i>similarity</i></span> which relates <span><i>objects</i></span> in the <span><i>evaluation environment</i></span> to the corresponding <span><i>objects</i></span> in</p>
<p>the <span><i>run-time environment</i></span>.</p>
<p>The constraints on <em>literal objects</em> described in this section apply only to <span><b>compile-file</b></span>; <span><b>eval</b></span> and <span><b>compile</b></span> do not copy or coalesce constants.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="3241-externalizable-objects">3.2.4.1 Externalizable Objects<a href="d-c-compilation.html#3241-externalizable-objects" class="hash-link" aria-label="Direct link to 3.2.4.1 Externalizable Objects" title="Direct link to 3.2.4.1 Externalizable Objects"></a></h3>
<!-- -->
<p>The fact that the <span><i>file compiler</i></span> represents <em>literal objects</em> externally in a <span><i>compiled file</i></span> and must later reconstruct suitable equivalents of those <span><i>objects</i></span> when that <span><i>file</i></span> is loaded imposes a need for constraints on the nature of the <span><i>objects</i></span> that can be used as <em>literal objects</em> in <span><i>code</i></span> to be processed by the <span><i>file compiler</i></span> .</p>
<p>An <span><i>object</i></span> that can be used as a <em>literal object</em> in <span><i>code</i></span> to be processed by the <span><i>file compiler</i></span> is called an <span><i>externalizable object</i></span>.</p>
<p>We define that two <span><i>objects</i></span> are <span><i>similar</i></span> if they satisfy a two-place conceptual equivalence predicate (defined below), which is independent of the <em>Lisp image</em> so that the two <span><i>objects</i></span> in different <em>Lisp images</em> can be understood to be equivalent under this predicate. Further, by inspecting the definition of this conceptual predicate, the programmer can anticipate what aspects of an <span><i>object</i></span> are reliably preserved by <em>file compilation</em>.</p>
<p>The <span><i>file compiler</i></span> must cooperate with the <span><i>loader</i></span> in order to assure that in each case where an <span><i>externalizable object</i></span> is processed as a <em>literal object</em>, the <span><i>loader</i></span> will construct a <em>similar object</em>.</p>
<p>The set of <span><i>objects</i></span> that are <span><i>externalizable objects</i></span> are those for which the new conceptual term “<span><i>similar</i></span>” is defined, such that when a <span><i>compiled file</i></span> is <em>loaded</em>, an <span><i>object</i></span> can be constructed which</p>
<p>can be shown to be <span><i>similar</i></span> to the original <span><i>object</i></span> which existed at the time the <span><i>file compiler</i></span> was operating.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="3242-similarity-of-literal-objects">3.2.4.2 Similarity of Literal Objects<a href="d-c-compilation.html#3242-similarity-of-literal-objects" class="hash-link" aria-label="Direct link to 3.2.4.2 Similarity of Literal Objects" title="Direct link to 3.2.4.2 Similarity of Literal Objects"></a></h3>
<!-- -->
<!-- -->
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="32421-similarity-of-aggregate-objects">3.2.4.2.1 Similarity of Aggregate Objects<a href="d-c-compilation.html#32421-similarity-of-aggregate-objects" class="hash-link" aria-label="Direct link to 3.2.4.2.1 Similarity of Aggregate Objects" title="Direct link to 3.2.4.2.1 Similarity of Aggregate Objects"></a></h4>
<!-- -->
<p>Of the <span><i>types</i></span> over which <span><i>similarity</i></span> is defined, some are treated as aggregate objects. For these types, <span><i>similarity</i></span> is defined recursively. We say that an <span><i>object</i></span> of these types has certain “basic qualities” and to satisfy the <span><i>similarity</i></span> relationship, the values of the corresponding qualities of the two <span><i>objects</i></span> must also be similar.</p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="32422-definition-of-similarity">3.2.4.2.2 Definition of Similarity<a href="d-c-compilation.html#32422-definition-of-similarity" class="hash-link" aria-label="Direct link to 3.2.4.2.2 Definition of Similarity" title="Direct link to 3.2.4.2.2 Definition of Similarity"></a></h4>
<!-- -->
<p>Two <em>objects S</em> (in <span><i>source code</i></span>) and <em>C</em> (in <span><i>compiled code</i></span>) are defined to be <span><i>similar</i></span> if and only if they are both of one of the <span><i>types</i></span> listed here (or defined by the <span><i>implementation</i></span>) and they both satisfy all additional requirements of <span><i>similarity</i></span> indicated for that <span><i>type</i></span>.</p>
<span><b>number</b></span>
<p>Two <em>numbers S</em> and <em>C</em> are <span><i>similar</i></span> if they are of the same <span><i>type</i></span> and represent the same mathematical value.</p>
<span><b>character</b></span>
<p>Two <em>simple characters S</em> and <em>C</em> are <span><i>similar</i></span> if they have <em>similar code attributes</em>.</p>
<p><span><i>Implementations</i></span> providing additional, <em>implementation-defined attributes</em> must define whether and how <em>non-simple characters</em> can be regarded as <span><i>similar</i></span> .</p>
<span><b>symbol</b></span>
<p>Two <em>apparently uninterned symbols S</em> and <em>C</em> are <span><i>similar</i></span> if their <span><i>names</i></span> are <span><i>similar</i></span> .</p>
<p>Two <span><i>interned</i></span> symbols <em>S</em> and <em>C</em> are <span><i>similar</i></span> if their <span><i>names</i></span> are <span><i>similar</i></span> , and if either <em>S</em> is accessible in the <span><i>current package</i></span> at compile time and <em>C</em> is accessible in the <span><i>current package</i></span> at load time, or <em>C</em> is accessible in the <span><i>package</i></span> that is <span><i>similar</i></span> to the <span><i>home package</i></span> of <em>S</em>.</p>
<p>(Note that <span><i>similarity</i></span> of <span><i>symbols</i></span> is dependent on neither the <span><i>current readtable</i></span> nor how the <span><i>function</i></span> <span><b>read</b></span> would parse the <span><i>characters</i></span> in the <span><i>name</i></span> of the <span><i>symbol</i></span>.)</p>
<span><b>package</b></span>
<p>Two <em>packages S</em> and <em>C</em> are <span><i>similar</i></span> if their <span><i>names</i></span> are <span><i>similar</i></span> .</p>
<p>Note that although a <em>package object</em> is an <span><i>externalizable object</i></span>, the programmer is responsible for ensuring that the corresponding <span><i>package</i></span> is already in existence when code</p>
<p>referencing it as a <em>literal object</em> is <em>loaded</em>. The <span><i>loader</i></span> finds the corresponding <em>package object</em> as if by calling <span><b>find-package</b></span> with that <span><i>name</i></span> as an <span><i>argument</i></span>. An error is signaled by the <span><i>loader</i></span> if no <span><i>package</i></span> exists at load time.</p>
<span><b>random-state</b></span>
<p>Two <em>random states S</em> and <em>C</em> are <span><i>similar</i></span> if <em>S</em> would always produce the same sequence of pseudo-random numbers as a <span><i>copy</i></span><sub>5</sub> of <em>C</em> when given as the <em>random-state argument</em> to the <span><i>function</i></span> <span><b>random</b></span>, assuming equivalent <em>limit arguments</em> in each case.</p>
<p>(Note that since <em>C</em> has been processed by the <span><i>file compiler</i></span> , it cannot be used directly as an <span><i>argument</i></span> to <span><b>random</b></span> because <span><b>random</b></span> would perform a side effect.)</p>
<span><b>cons</b></span>
<p>Two <em>conses</em>, <em>S</em> and <em>C</em>, are <span><i>similar</i></span> if the <span><i>car</i></span> <sub>2</sub> of <em>S</em> is <span><i>similar</i></span> to the <span><i>car</i></span> <sub>2</sub> of <em>C</em>, and the <span><i>cdr</i></span> <sub>2</sub> of <em>S</em> is <span><i>similar</i></span> to the <span><i>cdr</i></span> <sub>2</sub> of <em>C</em>.</p>
<span><b>array</b></span>
<p>Two one-dimensional <span><i>arrays</i></span>, <em>S</em> and <em>C</em>, are <span><i>similar</i></span> if the <span><i>length</i></span> of <em>S</em> is <span><i>similar</i></span> to the <span><i>length</i></span> of <em>C</em>, the <span><i>actual array element type</i></span> of <em>S</em> is <span><i>similar</i></span> to the <span><i>actual array element type</i></span> of <em>C</em>, and each <em>active element</em> of <em>S</em> is <span><i>similar</i></span> to the corresponding <span><i>element</i></span> of <em>C</em>.</p>
<p>Two <span><i>arrays</i></span> of <span><i>rank</i></span> other than one, <em>S</em> and <em>C</em>, are <span><i>similar</i></span> if the <span><i>rank</i></span> of <em>S</em> is <span><i>similar</i></span> to the <span><i>rank</i></span> of <em>C</em>, each <span><i>dimension</i></span><sub>1</sub> of <em>S</em> is <span><i>similar</i></span> to the corresponding <span><i>dimension</i></span><sub>1</sub> of <em>C</em>, the <span><i>actual array element type</i></span> of <em>S</em> is <span><i>similar</i></span> to the <span><i>actual array element type</i></span> of <em>C</em>, and each <span><i>element</i></span> of <em>S</em> is <span><i>similar</i></span> to the corresponding <span><i>element</i></span> of <em>C</em>.</p>
<p>In addition, if <em>S</em> is a <span><i>simple array</i></span>, then <em>C</em> must also be a <span><i>simple array</i></span>. If <em>S</em> is a <span><i>displaced array</i></span>, has a <span><i>fill pointer</i></span> , or is <span><i>actually adjustable</i></span>, <em>C</em> is permitted to lack any or all of these qualities.</p>
<span><b>hash-table</b></span>
<p>Two <em>hash tables S</em> and <em>C</em> are <span><i>similar</i></span> if they meet the following three requirements: 1. They both have the same test (<em>e.g.</em>, they are both <span><b>eql</b></span> <span><i>hash tables</i></span>).</p>
<p>2. There is a unique one-to-one correspondence between the keys of the two <span><i>hash tables</i></span>, such that the corresponding keys are <span><i>similar</i></span> .</p>
<p>3. For all keys, the values associated with two corresponding keys are <span><i>similar</i></span> .</p>
<p>If there is more than one possible one-to-one correspondence between the keys of <em>S</em> and <em>C</em>, the consequences are unspecified. A <span><i>conforming program</i></span> cannot use a table such as <em>S</em> as an <em>externalizable constant</em>.</p>
<span><b>pathname</b></span>
<p>Two <em>pathnames S</em> and <em>C</em> are <span><i>similar</i></span> if all corresponding <em>pathname components</em> are <span><i>similar</i></span> .</p>
<span><b>function</b></span>
<p><span><i>Functions</i></span> are not <span><i>externalizable objects</i></span>.</p>
<p><span><b>structure-object</b></span> and <span><b>standard-object</b></span></p>
<p>A general-purpose concept of <span><i>similarity</i></span> does not exist for <span><i>structures</i></span> and <span><i>standard objects</i></span>. However, a <span><i>conforming program</i></span> is permitted to define a <span><b>make-load-form</b></span> <span><i>method</i></span> for any <em>class K</em> defined by that <span><i>program</i></span> that is a <span><i>subclass</i></span> of either <span><b>structure-object</b></span> or <span><b>standard-object</b></span>. The effect of such a <span><i>method</i></span> is to define that an <em>object S</em> of <em>type K</em> in <span><i>source code</i></span> is <span><i>similar</i></span> to an <em>object C</em> of <em>type K</em> in <span><i>compiled code</i></span> if <em>C</em> was constructed from <span><i>code</i></span> produced by calling <span><b>make-load-form</b></span> on <em>S</em>.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="3243-extensions-to-similarity-rules">3.2.4.3 Extensions to Similarity Rules<a href="d-c-compilation.html#3243-extensions-to-similarity-rules" class="hash-link" aria-label="Direct link to 3.2.4.3 Extensions to Similarity Rules" title="Direct link to 3.2.4.3 Extensions to Similarity Rules"></a></h3>
<!-- -->
<p>Some <span><i>objects</i></span>, such as <span><i>streams</i></span>, <strong>readtables</strong>, and <strong>methods</strong> are not <span><i>externalizable objects</i></span> under the definition of similarity given above. That is, such <span><i>objects</i></span> may not portably appear as <em>literal objects</em> in <span><i>code</i></span> to be processed by the <span><i>file compiler</i></span> .</p>
<p>An <span><i>implementation</i></span> is permitted to extend the rules of similarity, so that other kinds of <span><i>objects</i></span> are <span><i>externalizable objects</i></span> for that <span><i>implementation</i></span>.</p>
<p>If for some kind of <span><i>object</i></span>, <span><i>similarity</i></span> is neither defined by this specification nor by the <span><i>implementation</i></span>, then the <span><i>file compiler</i></span> must signal an error upon encountering such an <span><i>object</i></span> as a <em>literal constant</em>.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="3244-additional-constraints-on-externalizable-objects">3.2.4.4 Additional Constraints on Externalizable Objects<a href="d-c-compilation.html#3244-additional-constraints-on-externalizable-objects" class="hash-link" aria-label="Direct link to 3.2.4.4 Additional Constraints on Externalizable Objects" title="Direct link to 3.2.4.4 Additional Constraints on Externalizable Objects"></a></h3>
<!-- -->
<p>If two <em>literal objects</em> appearing in the source code for a single file processed with the <span><i>file compiler</i></span> are the <span><i>identical</i></span>, the corresponding <span><i>objects</i></span> in the <span><i>compiled code</i></span> must also be the <span><i>identical</i></span>. With the exception of <span><i>symbols</i></span> and <span><i>packages</i></span>, any two <em>literal objects</em> in <span><i>code</i></span> being processed by the <span><i>file compiler</i></span> may be <em>coalesced</em> if and only if they are <span><i>similar</i></span> ; if they are either both <span><i>symbols</i></span> or both <span><i>packages</i></span>, they may only be <em>coalesced</em> if and only if they are <span><i>identical</i></span>.</p>
<p><span><i>Objects</i></span> containing circular references can be <span><i>externalizable objects</i></span>. The <span><i>file compiler</i></span> is required to preserve <span><b>eql</b></span>ness of substructures within a <span><i>file</i></span>. Preserving <span><b>eql</b></span>ness means that subobjects that are the <span><i>same</i></span> in the <span><i>source code</i></span> must be the <span><i>same</i></span> in the corresponding <span><i>compiled code</i></span>.</p>
<p>In addition, the following are constraints on the handling of <em>literal objects</em> by the <span><i>file compiler</i></span> :</p>
<p><span><b>array:</b></span> If an <span><i>array</i></span> in the source code is a <span><i>simple array</i></span>, then the corresponding <span><i>array</i></span> in the compiled code will also be a <span><i>simple array</i></span>. If an <span><i>array</i></span> in the source code is displaced, has a <span><i>fill pointer</i></span> , or is <span><i>actually adjustable</i></span>, the corresponding <span><i>array</i></span> in the compiled code might lack any or all of these qualities. If an <span><i>array</i></span> in the source code has a fill pointer, then the corresponding <span><i>array</i></span> in the compiled code might be only the size implied by the fill pointer.</p>
<p><strong>packages:</strong> The loader is required to find the corresponding <em>package object</em> as if by calling <span><b>find-package</b></span> with the package name as an argument. An error of <span><i>type</i></span> <span><b>package-error</b></span> is signaled if no <span><i>package</i></span> of that name exists at load time.</p>
<p><span><b>random-state:</b></span> A constant <span><i>random state</i></span> object cannot be used as the state argument to the <span><i>function</i></span> <span><b>random</b></span> because <span><b>random</b></span> modifies this data structure.</p>
<p><strong>structure, standard-object:</strong> <span><i>Objects</i></span> of <span><i>type</i></span> <span><b>structure-object</b></span> and <span><b>standard-object</b></span> may appear in compiled constants if there is an appropriate <span><b>make-load-form</b></span> method defined for that <span><i>type</i></span>.</p>
<p>The <span><i>file compiler</i></span> calls <span><b>make-load-form</b></span> on any <span><i>object</i></span> that is referenced as a <em>literal object</em> if the <span><i>object</i></span> is a <span><i>generalized instance</i></span> of <span><b>standard-object</b></span>, <span><b>structure-object</b></span>, <span><b>condition</b></span>, or any of a (possibly empty) <span><i>implementation-dependent</i></span> set of other <em>classes</em>. The <span><i>file compiler</i></span> only calls <span><b>make-load-form</b></span> once for any given <span><i>object</i></span> within a single <span><i>file</i></span>.</p>
<p><span><b>symbol:</b></span> In order to guarantee that <span><i>compiled files</i></span> can be <em>loaded</em> correctly, users must ensure that the <span><i>packages</i></span> referenced in those <span><i>files</i></span> are defined consistently at compile time and load time. <span><i>Conforming programs</i></span> must satisfy the following requirements:</p>
<p>1. The <span><i>current package</i></span> when a <span><i>top level form</i></span> in the <span><i>file</i></span> is processed by <span><b>compile-file</b></span> must be the same as the <span><i>current package</i></span> when the <span><i>code</i></span> corresponding to that <span><i>top level form</i></span> in the <span><i>compiled file</i></span> is executed by <span><b>load</b></span>. In particular:</p>
<p>a. Any <span><i>top level form</i></span> in a <span><i>file</i></span> that alters the <span><i>current package</i></span> must change it to</p>
<p>a <span><i>package</i></span> of the same <span><i>name</i></span> both at compile time and at load time.</p>
<p>b. If the first <em>non-atomic top level form</em> in the <span><i>file</i></span> is not an <span><b>in-package</b></span> <span><i>form</i></span>,</p>
<p>then the <span><i>current package</i></span> at the time <span><b>load</b></span> is called must be a <span><i>package</i></span> with</p>
<p>the same <span><i>name</i></span> as the package that was the <span><i>current package</i></span> at the time</p>
<p><span><b>compile-file</b></span> was called.</p>
<p>2. For all <span><i>symbols</i></span> appearing lexically within a <span><i>top level form</i></span> that were <span><i>accessible</i></span> in the <span><i>package</i></span> that was the <span><i>current package</i></span> during processing of that <span><i>top level form</i></span> at compile time, but whose <span><i>home package</i></span> was another <span><i>package</i></span>, at load time there must be a <span><i>symbol</i></span> with the same <span><i>name</i></span> that is <span><i>accessible</i></span> in both the load-time <span><i>current package</i></span> and in the <span><i>package</i></span> with the same <span><i>name</i></span> as the compile-time <span><i>home package</i></span>.</p>
<p>3. For all <span><i>symbols</i></span> represented in the <span><i>compiled file</i></span> that were <span><i>external symbols</i></span> in their <span><i>home package</i></span> at compile time, there must be a <span><i>symbol</i></span> with the same <span><i>name</i></span> that is an <span><i>external symbol</i></span> in the <span><i>package</i></span> with the same <span><i>name</i></span> at load time.</p>
<p>If any of these conditions do not hold, the <span><i>package</i></span> in which the <span><i>loader</i></span> looks for the affected <span><i>symbols</i></span> is unspecified. <span><i>Implementations</i></span> are permitted to signal an error or to define this behavior.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="325-exceptional-situations-in-the-compiler">3.2.5 Exceptional Situations in the Compiler<a href="d-c-compilation.html#325-exceptional-situations-in-the-compiler" class="hash-link" aria-label="Direct link to 3.2.5 Exceptional Situations in the Compiler" title="Direct link to 3.2.5 Exceptional Situations in the Compiler"></a></h2>
<!-- -->
<!-- -->
<p><span><b>compile</b></span> and <span><b>compile-file</b></span> are permitted to signal errors and warnings, including errors due to compile-time processing of (eval-when (<!-- -->:compile-toplevel<!-- -->) ...) forms, macro expansion, and conditions signaled by the compiler itself.</p>
<p><span><i>Conditions</i></span> of <span><i>type</i></span> <span><b>error</b></span> might be signaled by the compiler in situations where the compilation cannot proceed without intervention.</p>
<p>In addition to situations for which the standard specifies that <span><i>conditions</i></span> of <span><i>type</i></span> <span><b>warning</b></span> must or might be signaled, warnings might be signaled in situations where the compiler can determine that the consequences are undefined or that a run-time error will be signaled. Examples of this situation are as follows: violating type declarations, altering or assigning the value of a constant defined with <span><b>defconstant</b></span>, calling built-in Lisp functions with a wrong number of arguments or malformed keyword argument lists, and using unrecognized declaration specifiers.</p>
<p>The compiler is permitted to issue warnings about matters of programming style as conditions of <span><i>type</i></span> <span><b>style-warning</b></span>. Examples of this situation are as follows: redefining a function using a different argument list, calling a function with a wrong number of arguments, not declaring <span><b>ignore</b></span> of a local variable that is not referenced, and referencing a variable declared <span><b>ignore</b></span>.</p>
<p>Both <span><b>compile</b></span> and <span><b>compile-file</b></span> are permitted (but not required) to <span><i>establish</i></span> a <span><i>handler</i></span> for <span><i>conditions</i></span> of <span><i>type</i></span> <span><b>error</b></span>. For example, they might signal a warning, and restart compilation from some <span><i>implementation-dependent</i></span> point in order to let the compilation proceed without manual intervention.</p>
<p>Both <span><b>compile</b></span> and <span><b>compile-file</b></span> return three values, the second two indicating whether the source code being compiled contained errors and whether style warnings were issued.</p>
<p>Some warnings might be deferred until the end of compilation. See <span><b>with-compilation-unit</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-c-compilation.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="d-b-evaluation.html"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">3.1 Evaluation</div></a><a class="pagination-nav__link pagination-nav__link--next" href="d-d-declarations.html"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">3.3 Declarations</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-c-compilation.html#321-compiler-terminology" class="table-of-contents__link toc-highlight">3.2.1 Compiler Terminology</a></li><li><a href="d-c-compilation.html#322-compilation-semantics" class="table-of-contents__link toc-highlight">3.2.2 Compilation Semantics</a><ul><li><a href="d-c-compilation.html#3221-compiler-macros" class="table-of-contents__link toc-highlight">3.2.2.1 Compiler Macros</a><ul><li><a href="d-c-compilation.html#32211-purpose-of-compiler-macros" class="table-of-contents__link toc-highlight">3.2.2.1.1 Purpose of Compiler Macros</a></li><li><a href="d-c-compilation.html#32212-naming-of-compiler-macros" class="table-of-contents__link toc-highlight">3.2.2.1.2 Naming of Compiler Macros</a></li><li><a href="d-c-compilation.html#32213-when-compiler-macros-are-used" class="table-of-contents__link toc-highlight">3.2.2.1.3 When Compiler Macros Are Used</a><ul><li><a href="d-c-compilation.html#322131-notes-about-the-implementation-of-compiler-macros" class="table-of-contents__link toc-highlight">3.2.2.1.3.1 Notes about the Implementation of Compiler Macros</a></li></ul></li></ul></li><li><a href="d-c-compilation.html#3222-minimal-compilation" class="table-of-contents__link toc-highlight">3.2.2.2 Minimal Compilation</a></li><li><a href="d-c-compilation.html#3223-semantic-constraints" class="table-of-contents__link toc-highlight">3.2.2.3 Semantic Constraints</a></li></ul></li><li><a href="d-c-compilation.html#323-file-compilation" class="table-of-contents__link toc-highlight">3.2.3 File Compilation</a><ul><li><a href="d-c-compilation.html#3231-processing-of-top-level-forms" class="table-of-contents__link toc-highlight">3.2.3.1 Processing of Top Level Forms</a><ul><li><a href="d-c-compilation.html#32311-processing-of-defining-macros" class="table-of-contents__link toc-highlight">3.2.3.1.1 Processing of Defining Macros</a></li><li><a href="d-c-compilation.html#32312-constraints-on-macros-and-compiler-macros" class="table-of-contents__link toc-highlight">3.2.3.1.2 Constraints on Macros and Compiler Macros</a></li></ul></li></ul></li><li><a href="d-c-compilation.html#324-literal-objects-in-compiled-files" class="table-of-contents__link toc-highlight">3.2.4 Literal Objects in Compiled Files</a><ul><li><a href="d-c-compilation.html#3241-externalizable-objects" class="table-of-contents__link toc-highlight">3.2.4.1 Externalizable Objects</a></li><li><a href="d-c-compilation.html#3242-similarity-of-literal-objects" class="table-of-contents__link toc-highlight">3.2.4.2 Similarity of Literal Objects</a><ul><li><a href="d-c-compilation.html#32421-similarity-of-aggregate-objects" class="table-of-contents__link toc-highlight">3.2.4.2.1 Similarity of Aggregate Objects</a></li><li><a href="d-c-compilation.html#32422-definition-of-similarity" class="table-of-contents__link toc-highlight">3.2.4.2.2 Definition of Similarity</a></li></ul></li><li><a href="d-c-compilation.html#3243-extensions-to-similarity-rules" class="table-of-contents__link toc-highlight">3.2.4.3 Extensions to Similarity Rules</a></li><li><a href="d-c-compilation.html#3244-additional-constraints-on-externalizable-objects" class="table-of-contents__link toc-highlight">3.2.4.4 Additional Constraints on Externalizable Objects</a></li></ul></li><li><a href="d-c-compilation.html#325-exceptional-situations-in-the-compiler" class="table-of-contents__link toc-highlight">3.2.5 Exceptional Situations in the Compiler</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>