<!-- 95% W3C COMPLIANT, 95% CSS FREE, RAW HTML --> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"> <title>R5RsScheme Revised(5) Report on the Algorithmic Language Scheme</title> <style type="text/css"> <!-- pre { font-family: monospace } tt { font-family: monospace } code { font-family: monospace } p.flushright { text-align: right } p.flushleft { text-align: left } span.sc { font-variant: small-caps } span.sf { font-family: sans-serif } span.skribetitle { font-family: sans-serif; font-weight: bolder; font-size: x-large; } span.refscreen { } span.refprint { display: none; } --> </style> </head> <body class="chapter" bgcolor="#ffffff"> <table width="100%" class="skribetitle" cellspacing="0" cellpadding="0"><tbody> <tr><td align="center" bgcolor="#8381de"><div class="skribetitle"><strong><big><big><big>2. R5Rs<br/>Scheme Revised(5) Report on the Algorithmic Language Scheme -- Lexical conventions</big></big></big></strong></div><center> </center> </td></tr></tbody></table> <table cellpadding="3" cellspacing="0" width="100%" class="skribe-margins"><tr> <td align="left" valign="top" class="skribe-left-margin" width="20%" bgcolor="#dedeff"><div class="skribe-left-margin"> <br/><center id='center7573' ><table width="97%" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse;" frame="box" rules="none"><tbody> <tr bgcolor="#8381de"><th id="tc7563" align="center" colspan="1"><font color="#ffffff"><strong id='bold7561' >main page</strong></font></th></tr> <tr bgcolor="#ffffff"><td id="tc7570" align="center" colspan="1"><table width="100%" border="0" style="border-collapse: collapse;" frame="void" rules="none"><tbody> <tr><td id="tc7566" align="left" valign="top" colspan="1"><strong id='bold7565' >top:</strong></td><td id="tc7567" align="right" valign="top" colspan="1"><a href="r5rs.html#R5Rs-Scheme-Revised(5)-Report-on-the-Algorithmic-Language-Scheme" class="inbound">R5Rs<br/>Scheme Revised(5) Report on the Algorithmic Language Scheme</a></td></tr> </tbody></table> </td></tr> </tbody></table> </center> <br/><br/><center id='center7583' ><table width="97%" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse;" frame="box" rules="none"><tbody> <tr bgcolor="#8381de"><th id="tc7577" align="center" colspan="1"><font color="#ffffff"><strong id='bold7575' >Lexical conventions</strong></font></th></tr> <tr bgcolor="#ffffff"><td id="tc7580" align="center" colspan="1"><table cellspacing="1" cellpadding="1" width="100%" class="toc"> <tbody> <tr><td valign="top" align="left">2.1</td><td colspan="4" width="100%"><a href="r5rs-5.html#Identifiers">Identifiers</a></td></tr> <tr><td valign="top" align="left">2.2</td><td colspan="4" width="100%"><a href="r5rs-5.html#Whitespace-and-comments">Whitespace and comments</a></td></tr> <tr><td valign="top" align="left">2.3</td><td colspan="4" width="100%"><a href="r5rs-5.html#Other-notations">Other notations</a></td></tr> </tbody> </table> </td></tr> </tbody></table> </center> <br/><br/><center id='center7593' ><table width="97%" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse;" frame="box" rules="none"><tbody> <tr bgcolor="#8381de"><th id="tc7587" align="center" colspan="1"><font color="#ffffff"><strong id='bold7585' >Chapters</strong></font></th></tr> <tr bgcolor="#ffffff"><td id="tc7590" align="center" colspan="1"><table cellspacing="1" cellpadding="1" width="100%" class="toc"> <tbody> <tr><td valign="top" align="left"></td><td colspan="4" width="100%"><a href="r5rs-1.html#Summary">Summary</a></td></tr> <tr><td valign="top" align="left"></td><td colspan="4" width="100%"><a href="r5rs-2.html#Introduction">Introduction</a></td></tr> <tr><td valign="top" align="left"></td><td colspan="4" width="100%"><a href="r5rs-3.html#Table-of-contents">Table of contents</a></td></tr> <tr><td valign="top" align="left">1</td><td colspan="4" width="100%"><a href="r5rs-4.html#Overview-of-Scheme">Overview of Scheme</a></td></tr> <tr><td valign="top" align="left">2</td><td colspan="4" width="100%"><a href="r5rs-5.html#Lexical-conventions">Lexical conventions</a></td></tr> <tr><td valign="top" align="left">3</td><td colspan="4" width="100%"><a href="r5rs-6.html#Basic-concepts">Basic concepts</a></td></tr> <tr><td valign="top" align="left">4</td><td colspan="4" width="100%"><a href="r5rs-7.html#Expressions">Expressions</a></td></tr> <tr><td valign="top" align="left">5</td><td colspan="4" width="100%"><a href="r5rs-8.html#Program-structure">Program structure</a></td></tr> <tr><td valign="top" align="left">6</td><td colspan="4" width="100%"><a href="r5rs-9.html#Standard-procedures">Standard procedures</a></td></tr> <tr><td valign="top" align="left">7</td><td colspan="4" width="100%"><a href="r5rs-10.html#Formal-syntax-and-semantics">Formal syntax and semantics</a></td></tr> <tr><td valign="top" align="left">8</td><td colspan="4" width="100%"><a href="r5rs-11.html#Concepts">Concepts</a></td></tr> <tr><td valign="top" align="left">9</td><td colspan="4" width="100%"><a href="r5rs-12.html#Variables-and-Procedures">Variables and Procedures</a></td></tr> <tr><td valign="top" align="left"></td><td colspan="4" width="100%"><a href="r5rs-13.html#Notes">Notes</a></td></tr> <tr><td valign="top" align="left"></td><td colspan="4" width="100%"><a href="r5rs-14.html#Additional-material">Additional material</a></td></tr> <tr><td valign="top" align="left"></td><td colspan="4" width="100%"><a href="r5rs-15.html#Example">Example</a></td></tr> <tr><td valign="top" align="left"></td><td colspan="4" width="100%"><a href="r5rs-16.html#Bibliography">Bibliography</a></td></tr> </tbody> </table> </td></tr> </tbody></table> </center> </div></td> <td align="left" valign="top" class="skribe-body"><div class="skribe-body"> <a name="Lexical-conventions" class="mark"></a> This section gives an informal account of some of the lexical conventions used in writing Scheme programs. For a formal syntax of Scheme, see section <a href="r5rs-10.html#Formal-syntax" class="inbound">Formal syntax</a>.<br/><br/>Upper and lower case forms of a letter are never distinguished except within character and string constants. For example, <samp id='samp1299' >Foo</samp> is the same identifier as <samp id='samp1300' >FOO</samp>, and <tt id='tt1301' >#x1AB</tt> is the same number as <tt id='tt1302' >#X1ab</tt>.<br/><br/><!-- Identifiers --> <a name="Identifiers"></a> <div class="section-atitle"><table width="100%"><tr><td bgcolor="#dedeff"><h3><font color="black">2.1 Identifiers</font> </h3></td></tr></table> </div><div class="section"> <a name="Identifiers" class="mark"></a> Most identifiers allowed by other programming <a name="g1305" class="mark"></a>languages are also acceptable to Scheme. The precise rules for forming identifiers vary among implementations of Scheme, but in all implementations a sequence of letters, digits, and ``extended alphabetic characters'' that begins with a character that cannot begin a number is an identifier. In addition, <code id='code1307' >+</code>, <code id='code1308' >-</code>, and <code id='code1309' >...</code> are identifiers. <a name="g1311" class="mark"></a><a name="g1314" class="mark"></a><a name="g1317" class="mark"></a>Here are some examples of identifiers:<br/><br/><center id='center1322' ><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody> <tr><td bgcolor="#ffffcc"><pre class="prog" id='prog1320' >lambda q list->vector soup + V17a <=? a34kTMNs the-word-recursion-has-many-meanings </pre> </td></tr> </tbody></table></center> Extended alphabetic characters may be used within identifiers as if they were letters. The following are extended alphabetic characters:<br/><br/><center id='center1326' ><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody> <tr><td bgcolor="#ffffcc"><pre class="prog" id='prog1324' >! $ % & * + - . / : < = > ? @ ^ _ ~ </pre> </td></tr> </tbody></table></center> See section <a href="r5rs-10.html#Lexical-structure" class="inbound">Lexical structure</a> for a formal syntax of identifiers.<br/><br/>Identifiers have two uses within Scheme programs:<br/><br/><ul class="itemize" id='itemize1334' ><li>Any identifier may be used as a variable or as a syntactic keyword (see sections <a href="r5rs-6.html#Variables;-syntactic-keywords;-and-regions" class="inbound">Variables; syntactic keywords; and regions</a> and <a href="r5rs-7.html#Macros" class="inbound">Macros</a>).<br/><br/></li> <li>When an identifier appears as a literal or within a literal (see section <a href="r5rs-7.html#Literal-expressions" class="inbound">Literal expressions</a>), it is being used to denote a <em id='emph1331' >symbol</em> (see section <a href="r5rs-9.html#Symbols" class="inbound">Symbols</a>).<br/><br/></li> </ul> <a name="g1336" class="mark"></a><a name="g1339" class="mark"></a> </div><br> <!-- Whitespace and comments --> <a name="Whitespace-and-comments"></a> <div class="section-atitle"><table width="100%"><tr><td bgcolor="#dedeff"><h3><font color="black">2.2 Whitespace and comments</font> </h3></td></tr></table> </div><div class="section"> <a name="Whitespace-and-comments" class="mark"></a> "Whitespace" characters are spaces and newlines. <a name="g1342" class="mark"></a>(Implementations typically provide additional whitespace characters such as tab or page break.) Whitespace is used for improved readability and as necessary to separate tokens from each other, a token being an indivisible lexical unit such as an identifier or number, but is otherwise insignificant. Whitespace may occur between any two tokens, but not within a token. Whitespace may also occur inside a string, where it is significant.<br/><br/>A semicolon (<tt id='tt1345' >;</tt>) indicates the start of a comment. The comment continues to the <a name="g1347" class="mark"></a><a name="g1350" class="mark"></a>end of the line on which the semicolon appears. Comments are invisible to Scheme, but the end of the line is visible as whitespace. This prevents a comment from appearing in the middle of an identifier or number.<br/><br/><center id='center1358' ><table cellspacing="0" class="color" cellpadding="0" width="95%"><tbody> <tr><td bgcolor="#ffffcc"><pre class="prog" id='prog1356' ><font color="#ffa600"><em id='it7594' >;;; The FACT procedure computes the factorial</em></font> <font color="#ffa600"><em id='it7596' >;;; of a non-negative integer.</em></font> (<font color="#6959cf"><strong id='bold7598' >define</strong></font> <font color="#6959cf"><strong id='bold7600' >fact</strong></font> (<strong id='bold7602' >lambda</strong> (n) (<strong id='bold7603' >if</strong> (= n 0) 1 ;Base case: return 1 (* n (fact (- n 1)))))) </pre> </td></tr> </tbody></table></center> </div><br> <!-- Other notations --> <a name="Other-notations"></a> <div class="section-atitle"><table width="100%"><tr><td bgcolor="#dedeff"><h3><font color="black">2.3 Other notations</font> </h3></td></tr></table> </div><div class="section"> <a name="Other-notations" class="mark"></a> For a description of the notations used for numbers, see section <a href="r5rs-9.html#Numbers" class="inbound">Numbers</a>.<br/><br/><dl class="description" id='description1428' > <dt><tt id='tt1361' ><tt id='tt1360' >.: + -</tt></tt></dt> <dt><tt id='tt1362' > </tt></dt><dd>These are used in numbers, and may also occur anywhere in an identifier except as the first character. A delimited plus or minus sign by itself is also an identifier. A delimited period (not occurring within a number or identifier) is used in the notation for pairs (section <a href="r5rs-9.html#Pairs-and-lists" class="inbound">Pairs and lists</a>), and to indicate a rest-parameter in a formal parameter list (section <a href="r5rs-7.html#Procedures" class="inbound">Procedures</a>). A delimited sequence of three successive periods is also an identifier.<br/><br/></dd> <dt><tt id='tt1366' ><tt id='tt1365' >( )</tt></tt></dt> <dt><tt id='tt1367' > </tt></dt><dd>Parentheses are used for grouping and to notate lists (section <a href="r5rs-9.html#Pairs-and-lists" class="inbound">Pairs and lists</a>).<br/><br/></dd> <dt><tt id='tt1371' ><tt id='tt1370' >'</tt></tt></dt> <dt><tt id='tt1372' > </tt></dt><dd>The single quote character is used to indicate literal data (section <a href="r5rs-7.html#Literal-expressions" class="inbound">Literal expressions</a>).<br/><br/></dd> <dt><tt id='tt1376' ><tt id='tt1375' >`</tt></tt></dt> <dt><tt id='tt1377' > </tt></dt><dd>The backquote character is used to indicate almost-constant data (section <a href="r5rs-7.html#Quasiquotation" class="inbound">Quasiquotation</a>).<br/><br/></dd> <dt><tt id='tt1381' ><tt id='tt1380' >, ,@</tt></tt></dt> <dt><tt id='tt1382' > </tt></dt><dd>The character comma and the sequence comma at-sign are used in conjunction with backquote (section <a href="r5rs-7.html#Quasiquotation" class="inbound">Quasiquotation</a>).<br/><br/></dd> <dt><tt id='tt1386' ><tt id='tt1385' >"</tt></tt></dt> <dt><tt id='tt1387' > </tt></dt><dd>The double quote character is used to delimit strings (section <a href="r5rs-9.html#Strings" class="inbound">Strings</a>).<br/><br/></dd> <dt><tt id='tt1390' >\</tt></dt> <dt><tt id='tt1391' > </tt></dt><dd>Backslash is used in the syntax for character constants (section <a href="r5rs-9.html#Characters" class="inbound">Characters</a>) and as an escape character within string constants (section <a href="r5rs-9.html#Strings" class="inbound">Strings</a>).<br/><br/> </dd> <dt><tt id='tt1396' ><strong id='bold1395' ><tt id='tt1394' >[ ] { } |</tt></strong></tt></dt> <dt><tt id='tt1397' > </tt></dt><dd>Left and right square brackets and curly braces and vertical bar are reserved for possible future extensions to the language.<br/><br/></dd> <dt><tt id='tt1400' >#</tt></dt> <dt><tt id='tt1401' > </tt></dt><dd> Sharp sign is used for a variety of purposes depending on the character that immediately follows it:<br/><br/></dd> <dt><tt id='tt1405' ><tt id='tt1404' >#t</tt></tt></dt> <dt><tt id='tt1406' > </tt></dt> <dt><tt id='tt1408' ><tt id='tt1407' >#f</tt></tt></dt> <dt><tt id='tt1409' > </tt></dt><dd>These are the boolean constants (section <a href="r5rs-9.html#Booleans" class="inbound">Booleans</a>).<br/><br/></dd> <dt><tt id='tt1412' >#\</tt></dt> <dt><tt id='tt1413' > </tt></dt><dd>This introduces a character constant (section <a href="r5rs-9.html#Characters" class="inbound">Characters</a>).<br/><br/></dd> <dt><tt id='tt1416' >#</tt></dt> <dt><tt id='tt1418' ><tt id='tt1417' >(</tt></tt></dt> <dt><tt id='tt1419' > </tt></dt><dd>This introduces a vector constant (section <a href="r5rs-9.html#Vectors" class="inbound">Vectors</a>). Vector constants are terminated by <tt id='tt1420' >)</tt> .<br/><br/></dd> <dt><tt id='tt1424' ><tt id='tt1423' >#e #i #b #o #d #x #l</tt></tt></dt> <dt><tt id='tt1425' > </tt></dt><dd>These are used in the notation for numbers (section <a href="r5rs-9.html#Syntax-of-numerical-constants" class="inbound">Syntax of numerical constants</a>).<br/><br/></dd> </dl> </div><br> </div></td> </tr></table><div class="skribe-ending"> <hr> <p class="ending" id='paragraph7609' ><font size="-1"> This <span class="sc">Html</span> page has been produced by <a href="http://www.inria.fr/mimosa/fp/Skribe" class="http">Skribe</a>. <br/> Last update <em id='it7607' >Tue Jun 2 11:43:24 2009</em>.</font></p></div> </body> </html>