1
0
Fork 0
cl-sites/guile.html_node/Symbol-Read-Syntax.html

139 lines
5.8 KiB
HTML
Raw Normal View History

2024-12-17 12:49:28 +01:00
<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- This manual documents Guile version 3.0.10.
Copyright (C) 1996-1997, 2000-2005, 2009-2023 Free Software Foundation,
Inc.
Copyright (C) 2021 Maxime Devos
Copyright (C) 2024 Tomas Volf
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
copy of the license is included in the section entitled "GNU Free
Documentation License." -->
<title>Symbol Read Syntax (Guile Reference Manual)</title>
<meta name="description" content="Symbol Read Syntax (Guile Reference Manual)">
<meta name="keywords" content="Symbol Read Syntax (Guile Reference Manual)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content=".texi2any-real">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link href="index.html" rel="start" title="Top">
<link href="Concept-Index.html" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Symbols.html" rel="up" title="Symbols">
<link href="Symbol-Uninterned.html" rel="next" title="Symbol Uninterned">
<link href="Symbol-Primitives.html" rel="prev" title="Symbol Primitives">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {margin-left: 3.2em}
span:hover a.copiable-link {visibility: visible}
ul.mark-bullet {list-style-type: disc}
-->
</style>
<link rel="stylesheet" type="text/css" href="https://www.gnu.org/software/gnulib/manual.css">
</head>
<body lang="en">
<div class="subsubsection-level-extent" id="Symbol-Read-Syntax">
<div class="nav-panel">
<p>
Next: <a href="Symbol-Uninterned.html" accesskey="n" rel="next">Uninterned Symbols</a>, Previous: <a href="Symbol-Primitives.html" accesskey="p" rel="prev">Operations Related to Symbols</a>, Up: <a href="Symbols.html" accesskey="u" rel="up">Symbols</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h4 class="subsubsection" id="Extended-Read-Syntax-for-Symbols"><span>6.6.6.5 Extended Read Syntax for Symbols<a class="copiable-link" href="#Extended-Read-Syntax-for-Symbols"> &para;</a></span></h4>
<a class="index-entry-id" id="index-r7rs_002dsymbols"></a>
<p>The read syntax for a symbol is a sequence of letters, digits, and
<em class="dfn">extended alphabetic characters</em>, beginning with a character that
cannot begin a number. In addition, the special cases of <code class="code">+</code>,
<code class="code">-</code>, and <code class="code">...</code> are read as symbols even though numbers can
begin with <code class="code">+</code>, <code class="code">-</code> or <code class="code">.</code>.
</p>
<p>Extended alphabetic characters may be used within identifiers as if
they were letters. The set of extended alphabetic characters is:
</p>
<div class="example">
<pre class="example-preformatted">! $ % &amp; * + - . / : &lt; = &gt; ? @ ^ _ ~
</pre></div>
<p>In addition to the standard read syntax defined above (which is taken
from R5RS (see <a data-manual="r5rs" href="../r5rs_html/Formal-syntax.html#Formal-syntax">Formal syntax</a> in <cite class="cite">The Revised^5 Report on
Scheme</cite>)), Guile provides an extended symbol read syntax that allows the
inclusion of unusual characters such as space characters, newlines and
parentheses. If (for whatever reason) you need to write a symbol
containing characters not mentioned above, you can do so as follows.
</p>
<ul class="itemize mark-bullet">
<li>Begin the symbol with the characters <code class="code">#{</code>,
</li><li>write the characters of the symbol and
</li><li>finish the symbol with the characters <code class="code">}#</code>.
</li></ul>
<p>Here are a few examples of this form of read syntax. The first symbol
needs to use extended syntax because it contains a space character, the
second because it contains a line break, and the last because it looks
like a number.
</p>
<div class="example lisp">
<pre class="lisp-preformatted">#{foo bar}#
#{what
ever}#
#{4242}#
</pre></div>
<p>Although Guile provides this extended read syntax for symbols,
widespread usage of it is discouraged because it is not portable and not
very readable.
</p>
<p>Alternatively, if you enable the <code class="code">r7rs-symbols</code> read option (see
see <a class="pxref" href="Scheme-Read.html">Reading Scheme Code</a>), you can write arbitrary symbols using the same
notation used for strings, except delimited by vertical bars instead of
double quotes.
</p>
<div class="example">
<pre class="example-preformatted">|foo bar|
|\x3BB; is a greek lambda|
|\| is a vertical bar|
</pre></div>
<p>Note that there&rsquo;s also an <code class="code">r7rs-symbols</code> print option
(see <a class="pxref" href="Scheme-Write.html">Writing Scheme Values</a>). To enable the use of this notation, evaluate
one or both of the following expressions:
</p>
<div class="example">
<pre class="example-preformatted">(read-enable 'r7rs-symbols)
(print-enable 'r7rs-symbols)
</pre></div>
</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Symbol-Uninterned.html">Uninterned Symbols</a>, Previous: <a href="Symbol-Primitives.html">Operations Related to Symbols</a>, Up: <a href="Symbols.html">Symbols</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>