12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg">
- <head>
- <title>Keywords</title>
- <link rel="stylesheet" type="text/css" href="docbook-epub.css"/>
- <link rel="stylesheet" type="text/css" href="kawa.css"/>
- <script src="kawa-ebook.js" type="text/javascript"/>
- <meta name="generator" content="DocBook XSL-NS Stylesheets V1.79.1"/>
- <link rel="prev" href="Overall-Index.xhtml" title="Index"/>
- <link rel="next" href="Special-named-constants.xhtml" title="Special named constants"/>
- </head>
- <body>
- <header/>
- <section class="sect1" title="Keywords" epub:type="subchapter" id="Keywords">
- <div class="titlepage">
- <div>
- <div>
- <h2 class="title" style="clear: both">Keywords</h2>
- </div>
- </div>
- </div>
- <p>Keywords are similar to symbols.
- They are used mainly for specifying keyword arguments.
- </p>
- <p>Historically keywords have been self-evaluating (you did not need to
- quote them). This has changed: you must quote a keyword if you
- want a literal keyword value, and not quote it if it is used
- as a keyword argument.
- </p>
- <div class="literallayout">
- <p><a id="idm139667877565968" class="indexterm"/><span id="meta-keyword"/><em class="replaceable"><code>keyword</code></em> <code class="literal">::=</code> <a class="link" href="Lexical-syntax.xhtml#meta-identifier"><em class="replaceable"><code>identifier</code></em></a><code class="literal"><span class="bold"><strong>:</strong></span></code><br/>
- | <code class="literal"><span class="bold"><strong>#:</strong></span></code><a class="link" href="Lexical-syntax.xhtml#meta-identifier"><em class="replaceable"><code>identifier</code></em></a><br/>
- </p>
- </div>
- <p>The two syntaxes have the same meaning: The former is nicer-looking;
- the latter is more portable (and required if you use the
- <code class="literal">--r7rs</code> command-line flag).
- </p>
- <div class="blockquote">
- <blockquote class="blockquote">
- <p><span class="emphasis"><em>Details:</em></span>
- In r7rs and other Scheme standards the colon character
- does not have any special meaning, so <code class="literal">foo:</code> or <code class="literal">foo:bar</code>
- are just regular identifiers. Therefore some other Scheme variants
- that have keywords (including Guile and Racket) use the <code class="literal">#:</code> syntax.
- Kawa has some hacks so that <span class="emphasis"><em>most</em></span>
- standard Scheme programs that have colons in identifiers will work.
- However, for best compatibility, use the <code class="literal">--r7rs</code> command-line flag
- (which turns colon into a regular character in a symbol), and the
- <code class="literal">#:</code> syntax.
- </p>
- </blockquote>
- </div>
- <p>A keyword is a single token; therefore no whitespace is allowed between
- the <em class="replaceable"><code>identifier</code></em> and the colon or after the <code class="literal">#:</code>;
- these characters are not considered part of the name of the keyword.
- </p>
- <p class="synopsis" kind="Procedure"><span class="kind">Procedure</span><span class="ignore">: </span><a id="idm139667877554544" class="indexterm"/> <code class="function">keyword?</code> <em class="replaceable"><code>obj</code></em></p>
- <div class="blockquote">
- <blockquote class="blockquote">
- <p>Return <code class="literal">#t</code> if <em class="replaceable"><code>obj</code></em> is a keyword, and otherwise returns <code class="literal">#f</code>.
- </p>
- </blockquote>
- </div>
- <p class="synopsis" kind="Procedure"><span class="kind">Procedure</span><span class="ignore">: </span><a id="idm139667877549968" class="indexterm"/> <code class="function">keyword->string</code> <em class="replaceable"><code>keyword</code></em></p>
- <div class="blockquote">
- <blockquote class="blockquote">
- <p>Returns the name of <em class="replaceable"><code>keyword</code></em> as a string.
- The name does not include the final <code class="literal">#\:</code>.
- </p>
- </blockquote>
- </div>
- <p class="synopsis" kind="Procedure"><span class="kind">Procedure</span><span class="ignore">: </span><a id="idm139667877545680" class="indexterm"/> <code class="function">string->keyword</code> <em class="replaceable"><code>string</code></em></p>
- <div class="blockquote">
- <blockquote class="blockquote">
- <p>Returns the keyword whose name is <em class="replaceable"><code>string</code></em>.
- (The <em class="replaceable"><code>string</code></em> does not include a final <code class="literal">#\:</code>.)
- </p>
- </blockquote>
- </div>
- </section>
- <footer>
- <div class="navfooter">
- <p>
- Up: <a accesskey="u" href="Symbols-and-namespaces.xhtml">Symbols and namespaces</a></p>
- <p>
- Previous: <a accesskey="p" href="Namespaces.xhtml">Namespaces and compound symbols</a></p>
- <p>
- Next: <a accesskey="n" href="Special-named-constants.xhtml">Special named constants</a></p>
- </div>
- </footer>
- </body>
- </html>
|