141 lines
No EOL
62 KiB
HTML
141 lines
No EOL
62 KiB
HTML
<!doctype html>
|
||
<html lang="en" dir="ltr" class="docs-wrapper plugin-docs plugin-id-default docs-version-current docs-doc-page docs-doc-id-chap-2/c-d-interpretation-of-tokens" data-has-hydrated="false">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="generator" content="Docusaurus v3.0.1">
|
||
<title data-rh="true">2.3 Interpretation of Tokens | 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-2/c-d-interpretation-of-tokens"><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="2.3 Interpretation of Tokens | Common Lisp (New) Language Reference"><meta data-rh="true" name="description" content="2.3.1 Numbers as Tokens"><meta data-rh="true" property="og:description" content="2.3.1 Numbers as Tokens"><link data-rh="true" rel="icon" href="../img/favicon.ico"><link data-rh="true" rel="canonical" href="c-d-interpretation-of-tokens.html"><link data-rh="true" rel="alternate" href="c-d-interpretation-of-tokens.html" hreflang="en"><link data-rh="true" rel="alternate" href="c-d-interpretation-of-tokens.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="c-d-interpretation-of-tokens.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"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret menu__link--active" aria-expanded="true" href="c-b-character-syntax.html">2. Syntax</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="c-b-character-syntax.html">2.1 Character Syntax</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="c-c-reader-algorithm.html">2.2 Reader Algorithm</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="c-d-interpretation-of-tokens.html">2.3 Interpretation of Tokens</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="c-e-standard-macro-characters.html">2.4 Standard Macro Characters</a></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-3/d-b-evaluation.html">3. Evaluation and Compilation</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-4/e-b-introduction.html">4. Types and Classes</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-5/f-b-generalized-reference.html">5. Data and Control Flow</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="../chap-6/g-b-the-loop-facility.html">6. Iteration</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item 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">2. Syntax</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">2.3 Interpretation of Tokens</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>2.3 Interpretation of Tokens</h1>
|
||
<!-- -->
|
||
<!-- -->
|
||
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="231-numbers-as-tokens">2.3.1 Numbers as Tokens<a href="c-d-interpretation-of-tokens.html#231-numbers-as-tokens" class="hash-link" aria-label="Direct link to 2.3.1 Numbers as Tokens" title="Direct link to 2.3.1 Numbers as Tokens"></a></h2>
|
||
<!-- -->
|
||
<p>When a <span><i>token</i></span> is read, it is interpreted as a <span><i>number</i></span> or <span><i>symbol</i></span>. The <span><i>token</i></span> is interpreted as a <span><i>number</i></span> if it satisfies the syntax for numbers specified in Figure 2–9.</p>
|
||
<p>|</p><p><em>numeric-token</em> ::= <em>↓integer | ↓ratio | ↓float</em> </p><p><em>integer</em> ::= [<span><i>sign</i></span>] <em>{decimal-digit}</em><sup>+</sup><em>decimal-point |</em> [<span><i>sign</i></span>] <span><i>{digit}</i></span><sup>+</sup> </p><p><span><i>ratio</i></span> ::= [<span><i>sign</i></span>] <span><i>{digit}</i></span><sup>+</sup><em>slash {digit}</em><sup>+</sup> </p><p><span><i>float</i></span> ::= [<span><i>sign</i></span>] <em>{decimal-digit}</em>* <em>decimal-point {decimal-digit}</em><sup>+</sup>[<em>↓exponent<span><i>] </i></span>|</em> [<span><i>sign</i></span>] <em>{decimal-digit}</em><sup>+</sup>[<em>decimal-point {decimal-digit}</em>*] <em>↓exponent</em> </p><p><em>exponent</em> ::= <em>exponent-marker</em> [<span><i>sign</i></span>] <span><i>{digit}</i></span><sup>+</sup> </p><p><span><i>sign</i></span>—a <span><i>sign</i></span>. </p><p><span><i>slash</i></span>—a <span><i>slash</i></span> </p><p><em>decimal-point</em>—a <span><i>dot</i></span>. </p><p><em>exponent-marker</em>—an <span><i>exponent marker</i></span> . </p><p><em>decimal-digit</em>—a <span><i>digit</i></span> in <span><i>radix</i></span> 10. </p><p><span><i>digit</i></span>—a <span><i>digit</i></span> in the <em>current input radix</em> .</p>|<p></p>
|
||
<p>| :- |</p>
|
||
<p><strong>Figure 2–9. Syntax for Numeric Tokens</strong></p>
|
||
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="2311-potential-numbers-as-tokens">2.3.1.1 Potential Numbers as Tokens<a href="c-d-interpretation-of-tokens.html#2311-potential-numbers-as-tokens" class="hash-link" aria-label="Direct link to 2.3.1.1 Potential Numbers as Tokens" title="Direct link to 2.3.1.1 Potential Numbers as Tokens"></a></h3>
|
||
<!-- -->
|
||
<p>To allow implementors and future Common Lisp standards to extend the syntax of numbers, a syntax for <span><i>potential numbers</i></span> is defined that is more general than the syntax for numbers. A <span><i>token</i></span> is a <span><i>potential number</i></span> if it satisfies all of the following requirements:</p>
|
||
<p>1. The <i>token</i> consists entirely of <i>digits</i>, <i>signs</i>, <i>ratio markers</i>, decimal points (.), extension characters (<i><sup>∧</sup></i> or ), and number markers. A number marker is a letter. Whether a letter may be treated as a number marker depends on context, but no letter that is adjacent to another letter may ever be treated as a number marker. <i>Exponent markers</i> are number markers.</p>
|
||
<p>2. The <span><i>token</i></span> contains at least one digit. Letters may be considered to be digits, depending on the <span><i>current input base</i></span>, but only in <span><i>tokens</i></span> containing no decimal points.</p>
|
||
<p>3. The <i>token</i> begins with a <i>digit</i>, <i>sign</i>, decimal point, or extension character, but not a <i>package marker</i> . The syntax involving a leading <i>package marker</i> followed by a <i>potential number</i> is not well-defined. The consequences of the use of notation such as :1, :1/2, and :2<i><sup>∧</sup></i>3 in a position where an expression appropriate for <b>read</b> is expected are unspecified.</p>
|
||
<p>4. The <span><i>token</i></span> does not end with a sign.</p>
|
||
<p>If a <span><i>potential number</i></span> has number syntax, a <span><i>number</i></span> of the appropriate type is constructed and returned, if the <span><i>number</i></span> is representable in an implementation. A <span><i>number</i></span> will not be representable in an implementation if it is outside the boundaries set by the <span><i>implementation-dependent</i></span> constants for <span><i>numbers</i></span>. For example, specifying too large or too small an exponent for a <span><i>float</i></span> may make the <span><i>number</i></span> impossible to represent in the implementation. A <span><i>ratio</i></span> with denominator zero (such as -35/000) is not represented in any implementation. When a <span><i>token</i></span> with the syntax of a number cannot be converted to an internal <span><i>number</i></span> , an error of <span><i>type</i></span> <span><b>reader-error</b></span> is signaled. An error must not be signaled for specifying too many significant digits for a <span><i>float</i></span>; a truncated or rounded value should be produced.</p>
|
||
<p>If there is an ambiguity as to whether a letter should be treated as a digit or as a number marker, the letter is treated as a digit.</p>
|
||
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="23111-escape-characters-and-potential-numbers">2.3.1.1.1 Escape Characters and Potential Numbers<a href="c-d-interpretation-of-tokens.html#23111-escape-characters-and-potential-numbers" class="hash-link" aria-label="Direct link to 2.3.1.1.1 Escape Characters and Potential Numbers" title="Direct link to 2.3.1.1.1 Escape Characters and Potential Numbers"></a></h4>
|
||
<!-- -->
|
||
<p>A <span><i>potential number</i></span> cannot contain any <em>escape characters</em>. An <em>escape character</em> robs the following <span><i>character</i></span> of all syntactic qualities, forcing it to be strictly <span><i>alphabetic</i></span><sub>2</sub> and therefore unsuitable for use in a <span><i>potential number</i></span> . For example, all of the following representations are interpreted as <span><i>symbols</i></span>, not <span><i>numbers</i></span>:</p>
|
||
<p>\256 25\64 1.0\E6 |100| 3.14159 |3/4| 3/4 5||</p>
|
||
<p>In each case, removing the <em>escape character</em> (or <span><i>characters</i></span>) would cause the token to be a <span><i>potential number</i></span> .</p>
|
||
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="23112-examples-of-potential-numbers">2.3.1.1.2 Examples of Potential Numbers<a href="c-d-interpretation-of-tokens.html#23112-examples-of-potential-numbers" class="hash-link" aria-label="Direct link to 2.3.1.1.2 Examples of Potential Numbers" title="Direct link to 2.3.1.1.2 Examples of Potential Numbers"></a></h4>
|
||
<!-- -->
|
||
<p>As examples, the <span><i>tokens</i></span> in Figure 2–10 are <span><i>potential numbers</i></span>, but they are not actually numbers, and so are reserved <span><i>tokens</i></span>; a <span><i>conforming implementation</i></span> is permitted, but not required, to define their meaning.</p>
|
||
<div class="language-lisp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockTitle_Ktv7">Figure 2–10. Examples of reserved tokens</div><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-lisp codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">1b5000 777777q 1.7J -3/4+6.7J 12/25/83 27<i><sup>∧</sup></i>19 3<i><sup>∧</sup></i>4/5 6//7 3.1.2.6 <i><sup>∧</sup></i>-43<i><sup>∧</sup></i> </span><span class="token number" style="color:#36acaa">3.141</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">592</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">653</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">589</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">793</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">238</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">4</span><span class="token plain"> -3.7+2.6i-6.17j+19.6k</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
|
||
<p>The <span><i>tokens</i></span> in Figure 2–11 are not <span><i>potential numbers</i></span>; they are always treated as <span><i>symbols</i></span>:</p>
|
||
<div class="language-lisp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockTitle_Ktv7">Figure 2–11. Examples of symbols</div><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-lisp codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">/ /5 + 1+ 1- foo+ ab.cd <i><sup>∧ ∧</sup></i>/-</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
|
||
<p>The <span><i>tokens</i></span> in Figure 2–12 are <span><i>potential numbers</i></span> if the <span><i>current input base</i></span> is 16, but they are always treated as <span><i>symbols</i></span> if the <span><i>current input base</i></span> is 10.</p>
|
||
<div class="language-lisp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockTitle_Ktv7">Figure 2–12. Examples of symbols or potential numbers</div><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-lisp codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">bad-face 25-dec-83 a/b fad cafe f<i><sup>∧</sup></i></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
|
||
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="232-constructing-numbers-from-tokens">2.3.2 Constructing Numbers from Tokens<a href="c-d-interpretation-of-tokens.html#232-constructing-numbers-from-tokens" class="hash-link" aria-label="Direct link to 2.3.2 Constructing Numbers from Tokens" title="Direct link to 2.3.2 Constructing Numbers from Tokens"></a></h2>
|
||
<!-- -->
|
||
<p>A <em>real</em> is constructed directly from a corresponding numeric <span><i>token</i></span>; see Figure 2–9.</p>
|
||
<p>A <span><i>complex</i></span> is notated as a #C (or #c) followed by a <span><i>list</i></span> of two <em>reals</em>; see Section 2.4.8.11 (Sharpsign C).</p>
|
||
<p>The <span><i>reader macros</i></span> #B, #O, #X, and #R may also be useful in controlling the input <span><i>radix</i></span> in which <span><i>rationals</i></span> are parsed; see Section 2.4.8.7 (Sharpsign B), Section 2.4.8.8 (Sharpsign O), Section 2.4.8.9 (Sharpsign X), and Section 2.4.8.10 (Sharpsign R).</p>
|
||
<p>This section summarizes the full syntax for <span><i>numbers</i></span>.</p>
|
||
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="2321-syntax-of-a-rational">2.3.2.1 Syntax of a Rational<a href="c-d-interpretation-of-tokens.html#2321-syntax-of-a-rational" class="hash-link" aria-label="Direct link to 2.3.2.1 Syntax of a Rational" title="Direct link to 2.3.2.1 Syntax of a Rational"></a></h3>
|
||
<!-- -->
|
||
<!-- -->
|
||
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="23211-syntax-of-an-integer">2.3.2.1.1 Syntax of an Integer<a href="c-d-interpretation-of-tokens.html#23211-syntax-of-an-integer" class="hash-link" aria-label="Direct link to 2.3.2.1.1 Syntax of an Integer" title="Direct link to 2.3.2.1.1 Syntax of an Integer"></a></h4>
|
||
<!-- -->
|
||
<p><em>Integers</em> can be written as a sequence of <span><i>digits</i></span>, optionally preceded by a <span><i>sign</i></span> and optionally followed by a decimal point; see Figure 2–9. When a decimal point is used, the <span><i>digits</i></span> are taken to be in <span><i>radix</i></span> 10; when no decimal point is used, the <span><i>digits</i></span> are taken to be in radix given by the <span><i>current input base</i></span>.</p>
|
||
<p>For information on how <em>integers</em> are printed, see Section 22.1.3.1.1 (Printing Integers).</p>
|
||
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="23212-syntax-of-a-ratio">2.3.2.1.2 Syntax of a Ratio<a href="c-d-interpretation-of-tokens.html#23212-syntax-of-a-ratio" class="hash-link" aria-label="Direct link to 2.3.2.1.2 Syntax of a Ratio" title="Direct link to 2.3.2.1.2 Syntax of a Ratio"></a></h4>
|
||
<!-- -->
|
||
<p><span><i>Ratios</i></span> can be written as an optional <span><i>sign</i></span> followed by two non-empty sequences of <span><i>digits</i></span> separated by a <span><i>slash</i></span>; see Figure 2–9. The second sequence may not consist entirely of zeros. Examples of <span><i>ratios</i></span> are in Figure 2–13.</p>
|
||
<p>|</p><p>2/3 ;This is in canonical form </p>
|
||
<p>4/6 ;A non-canonical form for 2/3 </p>
|
||
<p>-17/23 ;A ratio preceded by a sign </p>
|
||
<p>-30517578125/32768 ;This is <code>(−5/2)</code><sup><code>15</code></sup> </p>
|
||
<p>10/5 ;The canonical form for this is <code>2</code> </p>
|
||
<p>#o-101/75 ;Octal notation for <code>−65/61</code> </p>
|
||
<p>#3r120/21 ;Ternary notation for <code>15/7</code> </p>
|
||
<p>#Xbc/ad ;Hexadecimal notation for <code>188/173</code> </p>
|
||
<p>#xFADED/FACADE ;Hexadecimal notation for<code> 1027565/16435934</code></p>|<p></p>
|
||
<p>| :- |</p>
|
||
<p><strong>Figure 2–13. Examples of Ratios</strong></p>
|
||
<p>For information on how <span><i>ratios</i></span> are printed, see Section 22.1.3.1.2 (Printing Ratios).</p>
|
||
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="2322-syntax-of-a-float">2.3.2.2 Syntax of a Float<a href="c-d-interpretation-of-tokens.html#2322-syntax-of-a-float" class="hash-link" aria-label="Direct link to 2.3.2.2 Syntax of a Float" title="Direct link to 2.3.2.2 Syntax of a Float"></a></h3>
|
||
<!-- -->
|
||
<p><span><i>Floats</i></span> can be written in either decimal fraction or computerized scientific notation: an optional sign, then a non-empty sequence of digits with an embedded decimal point, then an optional decimal exponent specification. If there is no exponent specifier, then the decimal point is required, and there must be digits after it. The exponent specifier consists of an <span><i>exponent marker</i></span> , an optional sign, and a non-empty sequence of digits. If no exponent specifier is present, or if the <span><i>exponent marker</i></span> e (or E) is used, then the format specified by <span><b>*read-default-float-format*</b></span> is used. See Figure 2–9.</p>
|
||
<p>An implementation may provide one or more kinds of <span><i>float</i></span> that collectively make up the <span><i>type</i></span> <span><b>float</b></span>. The letters s, f, d, and l (or their respective uppercase equivalents) explicitly specify the use of the <span><i>types</i></span> <span><b>short-float</b></span>, <span><b>single-float</b></span>, <span><b>double-float</b></span>, and <span><b>long-float</b></span>, respectively.</p>
|
||
<p>The internal format used for an external representation depends only on the <span><i>exponent marker</i></span> , and not on the number of decimal digits in the external representation.</p>
|
||
<p>Figure 2–14 contains examples of notations for <span><i>floats</i></span>:</p>
|
||
<p>|</p><p>0.0 ;Floating-point zero in default format </p><p>0E0 ;As input, this is also floating-point zero in default format. ;As output, this would appear as 0.0. </p><p>0e0 ;As input, this is also floating-point zero in default format. ;As output, this would appear as 0.0. </p><p>-.0 ;As input, this might be a zero or a minus zero, </p><p>; depending on whether the implementation supports </p><p>; a distinct minus zero. </p><p>;As output, 0.0 is zero and -0.0 is minus zero. </p><p>0. ;On input, the integer zero—<em>not</em> a floating-point number! ;Whether this appears as 0 or 0. on output depends </p><p>;on the <span><i>value</i></span> of <span><b>*print-radix*</b></span>. </p><p>0.0s0 ;A floating-point zero in short format </p><p>0s0 ;As input, this is a floating-point zero in short format. ;As output, such a zero would appear as 0.0s0 </p><p>; (or as 0.0 if <span><b>short-float</b></span> was the default format). </p><p>6.02E+23 ;Avogadro’s number, in default format </p><p>602E+21 ;Also Avogadro’s number, in default format</p>|<p></p>
|
||
<p>| :- |</p>
|
||
<p><strong>Figure 2–14. Examples of Floating-point numbers</strong></p>
|
||
<p>For information on how <span><i>floats</i></span> are printed, see Section 22.1.3.1.3 (Printing Floats).</p>
|
||
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="2323-syntax-of-a-complex">2.3.2.3 Syntax of a Complex<a href="c-d-interpretation-of-tokens.html#2323-syntax-of-a-complex" class="hash-link" aria-label="Direct link to 2.3.2.3 Syntax of a Complex" title="Direct link to 2.3.2.3 Syntax of a Complex"></a></h3>
|
||
<!-- -->
|
||
<p>A <span><i>complex</i></span> has a Cartesian structure, with a real part and an imaginary part each of which is a <em>real</em>. The parts of a <span><i>complex</i></span> are not necessarily <span><i>floats</i></span> but both parts must be of the same <span><i>type</i></span>: either both are <span><i>rationals</i></span>, or both are of the same <em>float subtype</em>. When constructing a <span><i>complex</i></span> , if the specified parts are not the same <span><i>type</i></span>, the parts are converted to be the same <span><i>type</i></span> internally</p>
|
||
<p>(<em>i.e.</em>, the <span><i>rational</i></span> part is converted to a <span><i>float</i></span>). An <span><i>object</i></span> of type (complex rational) is converted internally and represented thereafter as a <span><i>rational</i></span> if its imaginary part is an <em>integer</em> whose value is 0.</p>
|
||
<p>For further information, see Section 2.4.8.11 (Sharpsign C) and Section 22.1.3.1.4 (Printing Complexes).</p>
|
||
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="233-the-consing-dot">2.3.3 The Consing Dot<a href="c-d-interpretation-of-tokens.html#233-the-consing-dot" class="hash-link" aria-label="Direct link to 2.3.3 The Consing Dot" title="Direct link to 2.3.3 The Consing Dot"></a></h2>
|
||
<!-- -->
|
||
<p>If a <span><i>token</i></span> consists solely of dots (with no escape characters), then an error of <span><i>type</i></span> <span><b>reader-error</b></span> is signaled, except in one circumstance: if the <span><i>token</i></span> is a single <span><i>dot</i></span> and appears in a situation where <span><i>dotted pair</i></span> notation permits a <span><i>dot</i></span>, then it is accepted as part of such syntax and no error is signaled. See Section 2.4.1 (Left-Parenthesis).</p>
|
||
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="234-symbols-as-tokens">2.3.4 Symbols as Tokens<a href="c-d-interpretation-of-tokens.html#234-symbols-as-tokens" class="hash-link" aria-label="Direct link to 2.3.4 Symbols as Tokens" title="Direct link to 2.3.4 Symbols as Tokens"></a></h2>
|
||
<!-- -->
|
||
<p>Any <span><i>token</i></span> that is not a <span><i>potential number</i></span> , does not contain a <span><i>package marker</i></span> , and does not consist entirely of dots will always be interpreted as a <span><i>symbol</i></span>. Any <span><i>token</i></span> that is a <span><i>potential number</i></span> but does not fit the number syntax is a reserved <span><i>token</i></span> and has an <span><i>implementation-dependent</i></span> interpretation. In all other cases, the <span><i>token</i></span> is construed to be the name of a <span><i>symbol</i></span>.</p>
|
||
<p>Examples of the printed representation of <span><i>symbols</i></span> are in Figure 2–15. For presentational simplicity, these examples assume that the <span><i>readtable case</i></span> of the <span><i>current readtable</i></span> is <!-- -->:upcase<!-- -->.</p>
|
||
<p>|</p><p>FROBBOZ The <span><i>symbol</i></span> whose <span><i>name</i></span> is FROBBOZ. </p><p>frobboz Another way to notate the same <span><i>symbol</i></span>. </p><p>fRObBoz Yet another way to notate it. </p><p>unwind-protect A <span><i>symbol</i></span> with a hyphen in its <span><i>name</i></span>. </p><p>+$ The <span><i>symbol</i></span> named +$. </p><p>1+ The <span><i>symbol</i></span> named 1+. </p><p>+1 This is the <em>integer</em> 1, not a <span><i>symbol</i></span>. </p><p>pascal style This <span><i>symbol</i></span> has an underscore in its <span><i>name</i></span>. </p><p>file.rel.43 This <span><i>symbol</i></span> has periods in its <span><i>name</i></span>. </p><p>( The <span><i>symbol</i></span> whose <span><i>name</i></span> is (. </p><p>+1 The <span><i>symbol</i></span> whose <span><i>name</i></span> is +1. </p><p>+\1 Also the <span><i>symbol</i></span> whose <span><i>name</i></span> is +1. </p><p>\frobboz The <span><i>symbol</i></span> whose <span><i>name</i></span> is fROBBOZ. </p><p>3.14159265\s0 The <span><i>symbol</i></span> whose <span><i>name</i></span> is 3.14159265s0. </p><p>3.14159265\S0 A different <span><i>symbol</i></span>, whose <span><i>name</i></span> is 3.14159265S0. 3.14159265s0 A possible <span><i>short float</i></span> approximation to <em>π</em>.</p>|<p></p>
|
||
<p>| :- |</p>
|
||
<p><strong>Figure 2–15. Examples of the printed representation of symbols (Part 1 of 2)</strong></p>
|
||
<p>|</p><p>APL\360 The <span><i>symbol</i></span> whose <span><i>name</i></span> is APL\360. </p><p>apl\360 Also the <i>symbol</i> whose <i>name</i> is APL\360. (b<i><sup>∧</sup></i>2)\ -\ 4<em>a</em>c The <i>name</i> is (B<i><sup>∧</sup></i>2) - 4<em>A</em>C. </p><p>Parentheses and two spaces in it. </p><p>(\b<i><sup>∧</sup></i>2)\ -\4*\a*\c The <i>name</i> is (b<i><sup>∧</sup></i>2) - 4<em>a</em>c. </p><p>Letters explicitly lowercase. </p><p>|"| The same as writing ". </p><p>|(b<i><sup>∧</sup></i>2) - 4<em>a</em>c| The <i>name</i> is (b<i><sup>∧</sup></i>2) - 4<em>a</em>c. </p><p>|frobboz| The <span><i>name</i></span> is frobboz, not FROBBOZ. </p><p>|APL\360| The <span><i>name</i></span> is APL360. </p><p>|APL\360| The <span><i>name</i></span> is APL\360. </p><p>|apl\360| The <span><i>name</i></span> is apl\360. </p><p>|||| Same as || —the <span><i>name</i></span> is ||. </p><p>|(B<i><sup>∧</sup></i>2) - 4<em>A</em>C| The <i>name</i> is (B<i><sup>∧</sup></i>2) - 4<em>A</em>C. </p><p>Parentheses and two spaces in it. </p><p>|(b<i><sup>∧</sup></i>2) - 4<em>a</em>c| The <i>name</i> is (b<i><sup>∧</sup></i>2) - 4<em>a</em>c.</p>|<p></p>
|
||
<p>| :- |</p>
|
||
<p><strong>Figure 2–16. Examples of the printed representation of symbols (Part 2 of 2)</strong></p>
|
||
<p>In the process of parsing a <span><i>symbol</i></span>, it is <span><i>implementation-dependent</i></span> which <em>implementation-defined attributes</em> are removed from the <span><i>characters</i></span> forming a <span><i>token</i></span> that represents a <span><i>symbol</i></span>.</p>
|
||
<p>When parsing the syntax for a <span><i>symbol</i></span>, the <em>Lisp reader</em> looks up the <span><i>name</i></span> of that <span><i>symbol</i></span> in the <span><i>current package</i></span>. This lookup may involve looking in other <span><i>packages</i></span> whose <span><i>external symbols</i></span> are inherited by the <span><i>current package</i></span>. If the name is found, the corresponding <span><i>symbol</i></span> is returned. If the name is not found (that is, there is no <span><i>symbol</i></span> of that name <span><i>accessible</i></span> in the <span><i>current package</i></span>),</p>
|
||
<p>a new <span><i>symbol</i></span> is created and is placed in the <span><i>current package</i></span> as an <span><i>internal symbol</i></span>. The <span><i>current package</i></span> becomes the owner (<span><i>home package</i></span>) of the <span><i>symbol</i></span>, and the <span><i>symbol</i></span> becomes interned in the <span><i>current package</i></span>. If the name is later read again while this same <span><i>package</i></span> is current, the same <span><i>symbol</i></span> will be found and returned.</p>
|
||
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="235-valid-patterns-for-tokens">2.3.5 Valid Patterns for Tokens<a href="c-d-interpretation-of-tokens.html#235-valid-patterns-for-tokens" class="hash-link" aria-label="Direct link to 2.3.5 Valid Patterns for Tokens" title="Direct link to 2.3.5 Valid Patterns for Tokens"></a></h2>
|
||
<!-- -->
|
||
<p>The valid patterns for <span><i>tokens</i></span> are summarized in Figure 2–17.</p>
|
||
<p>|</p><p><em>nnnnn</em> a <span><i>number</i></span> </p><p><em>xxxxx</em> a <span><i>symbol</i></span> in the <span><i>current package</i></span> </p><p>:<em>xxxxx</em> a <span><i>symbol</i></span> in the the KEYWORD <span><i>package</i></span> </p><p><em>ppppp</em>:<em>xxxxx</em> an <span><i>external symbol</i></span> in the <em>ppppp package</em> </p><p><em>ppppp</em>::<em>xxxxx</em> a (possibly internal) <span><i>symbol</i></span> in the <em>ppppp package</em> :<em>nnnnn</em> undefined </p><p><em>ppppp</em>:<em>nnnnn</em> undefined </p><p><em>ppppp</em>::<em>nnnnn</em> undefined </p><p>::<em>aaaaa</em> undefined </p><p><em>aaaaa</em>: undefined </p><p><em>aaaaa</em>:<em>aaaaa</em>:<em>aaaaa</em> undefined</p>|<p></p>
|
||
<p>| :- |</p>
|
||
<p><strong>Figure 2–17. Valid patterns for tokens</strong></p>
|
||
<p>Note that <em>nnnnn</em> has number syntax, neither <em>xxxxx</em> nor <em>ppppp</em> has number syntax, and <em>aaaaa</em> has any syntax.</p>
|
||
<p>A summary of rules concerning <span><i>package markers</i></span> follows. In each case, examples are offered to illustrate the case; for presentational simplicity, the examples assume that the <span><i>readtable case</i></span> of the <span><i>current readtable</i></span> is <!-- -->:upcase<!-- -->.</p>
|
||
<p>1. If there is a single <span><i>package marker</i></span> , and it occurs at the beginning of the <span><i>token</i></span>, then the <span><i>token</i></span> is interpreted as a <span><i>symbol</i></span> in the KEYWORD <span><i>package</i></span>. It also sets the <span><b>symbol-value</b></span> of the newly-created <span><i>symbol</i></span> to that same <span><i>symbol</i></span> so that the <span><i>symbol</i></span> will self-evaluate.</p>
|
||
<p>For example, <!-- -->:bar<!-- -->, when read, interns BAR as an <span><i>external symbol</i></span> in the KEYWORD <span><i>package</i></span>.</p>
|
||
<p>2. If there is a single <span><i>package marker</i></span> not at the beginning or end of the <span><i>token</i></span>, then it divides the <span><i>token</i></span> into two parts. The first part specifies a <span><i>package</i></span>; the second part is the name of an <span><i>external symbol</i></span> available in that package.</p>
|
||
<p>For example, foo<!-- -->:bar<!-- -->, when read, looks up BAR among the <span><i>external symbols</i></span> of the <span><i>package</i></span> named FOO.</p>
|
||
<p>3. If there are two adjacent <span><i>package markers</i></span> not at the beginning or end of the <span><i>token</i></span>, then they divide the <span><i>token</i></span> into two parts. The first part specifies a <span><i>package</i></span>; the second part is the name of a <span><i>symbol</i></span> within that <span><i>package</i></span> (possibly an <span><i>internal symbol</i></span>).</p>
|
||
<p>For example, foo::bar, when read, interns BAR in the <span><i>package</i></span> named FOO.</p>
|
||
<p>4. If the <span><i>token</i></span> contains no <span><i>package markers</i></span>, and does not have <span><i>potential number</i></span> syntax, then the entire <span><i>token</i></span> is the name of the <span><i>symbol</i></span>. The <span><i>symbol</i></span> is looked up in the <span><i>current package</i></span>.</p>
|
||
<p>For example, bar, when read, interns BAR in the <span><i>current package</i></span>.</p>
|
||
<p>5. The consequences are unspecified if any other pattern of <span><i>package markers</i></span> in a <span><i>token</i></span> is used. All other uses of <span><i>package markers</i></span> within names of <span><i>symbols</i></span> are not defined by this standard but are reserved for <span><i>implementation-dependent</i></span> use.</p>
|
||
<p>For example, assuming the <span><i>readtable case</i></span> of the <span><i>current readtable</i></span> is <!-- -->:upcase<!-- -->, editor<!-- -->:buffer<!-- --> refers to the <span><i>external symbol</i></span> named BUFFER present in the <span><i>package</i></span> named editor, regardless of whether there is a <span><i>symbol</i></span> named BUFFER in the <span><i>current package</i></span>. If there is no <span><i>package</i></span> named editor, or if</p>
|
||
<p>no <span><i>symbol</i></span> named BUFFER is present in editor, or if BUFFER is not exported by editor, the reader signals a correctable error. If editor::buffer is seen, the effect is exactly the same as reading buffer with the EDITOR <span><i>package</i></span> being the <span><i>current package</i></span>.</p>
|
||
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="236-package-system-consistency-rules">2.3.6 Package System Consistency Rules<a href="c-d-interpretation-of-tokens.html#236-package-system-consistency-rules" class="hash-link" aria-label="Direct link to 2.3.6 Package System Consistency Rules" title="Direct link to 2.3.6 Package System Consistency Rules"></a></h2>
|
||
<!-- -->
|
||
<!-- -->
|
||
<p>The following rules apply to the package system as long as the <span><i>value</i></span> of <span><b>*package*</b></span> is not changed:</p>
|
||
<p><strong>Read-read consistency</strong></p>
|
||
<p>Reading the same <em>symbol name</em> always results in the <em>same symbol</em>.</p>
|
||
<p><strong>Print-read consistency</strong></p>
|
||
<p>An <em>interned symbol</em> always prints as a sequence of characters that, when read back in, yields the <em>same symbol</em>.</p>
|
||
<p>For information about how the <em>Lisp printer</em> treats <span><i>symbols</i></span>, see Section 22.1.3.3 (Printing Symbols).</p>
|
||
<p><strong>Print-print consistency</strong></p>
|
||
<p>If two interned <span><i>symbols</i></span> are not the <span><i>same</i></span>, then their printed representations will be different sequences of characters.</p>
|
||
<p>These rules are true regardless of any implicit interning. As long as the <span><i>current package</i></span> is not changed, results are reproducible regardless of the order of <em>loading</em> files or the exact history of what <span><i>symbols</i></span> were typed in when. If the <span><i>value</i></span> of <span><b>*package*</b></span> is changed and then changed back</p>
|
||
<p>to the previous value, consistency is maintained. The rules can be violated by changing the <span><i>value</i></span> of <span><b>*package*</b></span>, forcing a change to <span><i>symbols</i></span> or to <span><i>packages</i></span> or to both by continuing from an error, or calling one of the following <span><i>functions</i></span>: <span><b>unintern</b></span>, <span><b>unexport</b></span>, <span><b>shadow</b></span>, <span><b>shadowing-import</b></span>, or <span><b>unuse-package</b></span>.</p>
|
||
<p>An inconsistency only applies if one of the restrictions is violated between two of the named <span><i>symbols</i></span>. <span><b>shadow</b></span>, <span><b>unexport</b></span>, <span><b>unintern</b></span>, and <span><b>shadowing-import</b></span> can only affect the consistency of <span><i>symbols</i></span> with the same <span><i>names</i></span> (under <span><b>string=</b></span>) as the ones supplied as arguments.</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-2/c-d-interpretation-of-tokens.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="c-c-reader-algorithm.html"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">2.2 Reader Algorithm</div></a><a class="pagination-nav__link pagination-nav__link--next" href="c-e-standard-macro-characters.html"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">2.4 Standard Macro Characters</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="c-d-interpretation-of-tokens.html#231-numbers-as-tokens" class="table-of-contents__link toc-highlight">2.3.1 Numbers as Tokens</a><ul><li><a href="c-d-interpretation-of-tokens.html#2311-potential-numbers-as-tokens" class="table-of-contents__link toc-highlight">2.3.1.1 Potential Numbers as Tokens</a><ul><li><a href="c-d-interpretation-of-tokens.html#23111-escape-characters-and-potential-numbers" class="table-of-contents__link toc-highlight">2.3.1.1.1 Escape Characters and Potential Numbers</a></li><li><a href="c-d-interpretation-of-tokens.html#23112-examples-of-potential-numbers" class="table-of-contents__link toc-highlight">2.3.1.1.2 Examples of Potential Numbers</a></li></ul></li></ul></li><li><a href="c-d-interpretation-of-tokens.html#232-constructing-numbers-from-tokens" class="table-of-contents__link toc-highlight">2.3.2 Constructing Numbers from Tokens</a><ul><li><a href="c-d-interpretation-of-tokens.html#2321-syntax-of-a-rational" class="table-of-contents__link toc-highlight">2.3.2.1 Syntax of a Rational</a><ul><li><a href="c-d-interpretation-of-tokens.html#23211-syntax-of-an-integer" class="table-of-contents__link toc-highlight">2.3.2.1.1 Syntax of an Integer</a></li><li><a href="c-d-interpretation-of-tokens.html#23212-syntax-of-a-ratio" class="table-of-contents__link toc-highlight">2.3.2.1.2 Syntax of a Ratio</a></li></ul></li><li><a href="c-d-interpretation-of-tokens.html#2322-syntax-of-a-float" class="table-of-contents__link toc-highlight">2.3.2.2 Syntax of a Float</a></li><li><a href="c-d-interpretation-of-tokens.html#2323-syntax-of-a-complex" class="table-of-contents__link toc-highlight">2.3.2.3 Syntax of a Complex</a></li></ul></li><li><a href="c-d-interpretation-of-tokens.html#233-the-consing-dot" class="table-of-contents__link toc-highlight">2.3.3 The Consing Dot</a></li><li><a href="c-d-interpretation-of-tokens.html#234-symbols-as-tokens" class="table-of-contents__link toc-highlight">2.3.4 Symbols as Tokens</a></li><li><a href="c-d-interpretation-of-tokens.html#235-valid-patterns-for-tokens" class="table-of-contents__link toc-highlight">2.3.5 Valid Patterns for Tokens</a></li><li><a href="c-d-interpretation-of-tokens.html#236-package-system-consistency-rules" class="table-of-contents__link toc-highlight">2.3.6 Package System Consistency Rules</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> |