⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 r5rs-z-h-5.html

📁 scheme 标准(r5rs)。Scheme是MIT发布的基于Lambda运算的语言
💻 HTML
字号:
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html><!-- Generated from TeX source by tex2page, v 4o4,      (c) Dorai Sitaram, http://www.cs.rice.edu/~dorai/tex2page --><head><title>Revised^5 Report on the Algorithmic Language Scheme</title><link rel="stylesheet" type="text/css" href="r5rs-Z-C.css" title=default><meta name=robots content="noindex,follow"></head><body><p><div class=navigation>[Go to <span><a href="r5rs.html">first</a>, <a href="r5rs-Z-H-4.html">previous</a></span><span>, <a href="r5rs-Z-H-6.html">next</a></span> page<span>; &nbsp;&nbsp;</span><span><a href="r5rs-Z-H-2.html#%_toc_start">contents</a></span><span><span>; &nbsp;&nbsp;</span><a href="r5rs-Z-H-15.html#%_index_start">index</a></span>]</div><p><a name="%_chap_2"></a><h1 class=chapter><div class=chapterheading><a href="r5rs-Z-H-2.html#%_toc_%_chap_2">Chapter 2</a></div><p><a href="r5rs-Z-H-2.html#%_toc_%_chap_2">Lexical conventions</a></h1><p>This section gives an informal account of some of the lexicalconventions used in writing Scheme programs.  For a formal syntax ofScheme, see section&nbsp;<a href="r5rs-Z-H-10.html#%_sec_7.1">7.1</a>.<p>Upper and lower case forms of a letter are never distinguishedexcept within character and string constants.  For example, <tt>Foo</tt> isthe same identifier as <tt>FOO</tt>, and <tt>#x1AB</tt> is the same number as<tt>#X1ab</tt>.<p><a name="%_sec_2.1"></a><h2><a href="r5rs-Z-H-2.html#%_toc_%_sec_2.1">2.1&nbsp;&nbsp;Identifiers</a></h2><p><p>Most identifiers<a name="%_idx_14"></a> allowed by other programminglanguages are also acceptable to Scheme.  The precise rules for formingidentifiers vary among implementations of Scheme, but in allimplementations a sequence of letters, digits, and ``extended alphabeticcharacters'' that begins with a character that cannot begin a number isan identifier.  In addition, <tt>+</tt>, <tt>-</tt>, and <tt>...</tt> are identifiers. Here are some examples of identifiers:<p><tt><p>lambda&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;q<br>list-&gt;vector&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;soup<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;V17a<br>&lt;=?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a34kTMNs<br>the-word-recursion-has-many-meanings<p></tt><p>Extended alphabetic characters may be used within identifiers as ifthey were letters.  The following are extended alphabetic characters:<p><tt><p>! $&nbsp;%&nbsp;<code class=verbatim>&amp;</code>&nbsp;*&nbsp;+&nbsp;-&nbsp;.&nbsp;/&nbsp;: &lt;&nbsp;=&nbsp;&gt;&nbsp;?&nbsp;@&nbsp;<code class=verbatim>^</code>&nbsp;<code class=verbatim>_</code>&nbsp;<code class=verbatim>~</code>&nbsp;<p></tt><p>See section&nbsp;<a href="r5rs-Z-H-10.html#%_sec_7.1.1">7.1.1</a> for a formal syntax of identifiers.<p>Identifiers have two uses within Scheme programs:<p><ul><li>Any identifier may be used as a variable<a name="%_idx_16"></a>or as a syntactic keyword<a name="%_idx_18"></a>(see sections&nbsp;<a href="r5rs-Z-H-6.html#%_sec_3.1">3.1</a> and&nbsp;<a href="r5rs-Z-H-7.html#%_sec_4.3">4.3</a>).<p><li>When an identifier appears as a literal or within a literal(see section&nbsp;<a href="r5rs-Z-H-7.html#%_sec_4.1.2">4.1.2</a>), it is being used to denote a <em>symbol</em>(see section&nbsp;<a href="r5rs-Z-H-9.html#%_sec_6.3.3">6.3.3</a>).<p></ul><p><p><p><a name="%_sec_2.2"></a><h2><a href="r5rs-Z-H-2.html#%_toc_%_sec_2.2">2.2&nbsp;&nbsp;Whitespace and comments</a></h2><p><a name="%_idx_20"></a><em>Whitespace</em> characters are spaces and newlines.(Implementations typically provide additional whitespace characters suchas tab or page break.)  Whitespace is used for improved readability andas necessary to separate tokens from each other, a token being anindivisible lexical unit such as an identifier or number, but isotherwise insignificant.  Whitespace may occur between any two tokens,but not within a token.  Whitespace may also occur inside a string,where it is significant.<p>A semicolon (<tt>;</tt>) indicates the start of acomment.<a name="%_idx_22"></a><a name="%_idx_24"></a>  The comment continues to theend of the line on which the semicolon appears.  Comments are invisibleto Scheme, but the end of the line is visible as whitespace.  Thisprevents a comment from appearing in the middle of an identifier ornumber.<p><tt><p>;;;&nbsp;The&nbsp;FACT&nbsp;procedure&nbsp;computes&nbsp;the&nbsp;factorial<br>;;;&nbsp;of&nbsp;a&nbsp;non-negative&nbsp;integer.<br>(define&nbsp;fact<br>&nbsp;&nbsp;(lambda&nbsp;(n)<br>&nbsp;&nbsp;&nbsp;&nbsp;(if&nbsp;(=&nbsp;n&nbsp;0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;Base&nbsp;case:&nbsp;return&nbsp;1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;n&nbsp;(fact&nbsp;(-&nbsp;n&nbsp;1))))))<p></tt><p><a name="%_sec_2.3"></a><h2><a href="r5rs-Z-H-2.html#%_toc_%_sec_2.3">2.3&nbsp;&nbsp;Other notations</a></h2><p><p>For a description of the notations used for numbers, seesection&nbsp;<a href="r5rs-Z-H-9.html#%_sec_6.2">6.2</a>.<p><p><ul><p><li><b><tt>. + -</tt></b>&nbsp;&nbsp;These are used in numbers, and may also occur anywhere in an identifierexcept as the first character.  A delimited plus or minus sign by itselfis also an identifier.A delimited period (not occurring within a number or identifier) is usedin the notation for pairs (section&nbsp;<a href="r5rs-Z-H-9.html#%_sec_6.3.2">6.3.2</a>), and to indicate arest-parameter in a  formal parameter list (section&nbsp;<a href="r5rs-Z-H-7.html#%_sec_4.1.4">4.1.4</a>).A delimited sequence of three successive periods is also an identifier.<p><li><b><tt>( )</tt></b>&nbsp;&nbsp;Parentheses are used for grouping and to notate lists(section&nbsp;<a href="r5rs-Z-H-9.html#%_sec_6.3.2">6.3.2</a>).<p><li><b><tt>'</tt></b>&nbsp;&nbsp;The single quote character is used to indicate literal data (section&nbsp;<a href="r5rs-Z-H-7.html#%_sec_4.1.2">4.1.2</a>).<p><li><b><tt>`</tt></b>&nbsp;&nbsp;The backquote character is used to indicate almost-constantdata (section&nbsp;<a href="r5rs-Z-H-7.html#%_sec_4.2.6">4.2.6</a>).<p><li><b><tt>, ,@</tt></b>&nbsp;&nbsp;The character comma and the sequence comma at-sign are used in conjunctionwith backquote (section&nbsp;<a href="r5rs-Z-H-7.html#%_sec_4.2.6">4.2.6</a>).<p><li><b><tt>&quot;</tt></b>&nbsp;&nbsp;The double quote character is used to delimit strings (section&nbsp;<a href="r5rs-Z-H-9.html#%_sec_6.3.5">6.3.5</a>).<p><li><b><tt>\</tt></b>&nbsp;&nbsp;Backslash is used in the syntax for character constants(section&nbsp;<a href="r5rs-Z-H-9.html#%_sec_6.3.4">6.3.4</a>) and as an escape character within stringconstants (section&nbsp;<a href="r5rs-Z-H-9.html#%_sec_6.3.5">6.3.5</a>).<p><li><b><code class=verbatim>[ ] { } |</code></b>&nbsp;&nbsp;Left and right square brackets and curly braces and vertical barare reserved for possible future extensions to the language.<p><li><b><tt>#</tt></b>&nbsp;&nbsp; Sharp sign is used for a variety of purposes depending onthe character that immediately follows it:<p><li><b><tt>#t</tt> <tt>#f</tt></b>&nbsp;&nbsp;These are the boolean constants (section&nbsp;<a href="r5rs-Z-H-9.html#%_sec_6.3.1">6.3.1</a>).<p><li><b><tt>#</tt><tt>\</tt></b>&nbsp;&nbsp;This introduces a character constant (section&nbsp;<a href="r5rs-Z-H-9.html#%_sec_6.3.4">6.3.4</a>).<p><li><b><tt>#</tt><tt>(</tt></b>&nbsp;&nbsp;This introduces a vector constant (section&nbsp;<a href="r5rs-Z-H-9.html#%_sec_6.3.6">6.3.6</a>).  Vector constantsare terminated by&nbsp;<tt>)</tt>&nbsp;.<p><li><b><tt>#e #i #b #o #d #x</tt></b>&nbsp;&nbsp;These are used in the notation for numbers (section&nbsp;<a href="r5rs-Z-H-9.html#%_sec_6.2.4">6.2.4</a>).<p></ul><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<p><p><div class=navigation>[Go to <span><a href="r5rs.html">first</a>, <a href="r5rs-Z-H-4.html">previous</a></span><span>, <a href="r5rs-Z-H-6.html">next</a></span> page<span>; &nbsp;&nbsp;</span><span><a href="r5rs-Z-H-2.html#%_toc_start">contents</a></span><span><span>; &nbsp;&nbsp;</span><a href="r5rs-Z-H-15.html#%_index_start">index</a></span>]</div><p></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -