Keywords.xhtml 5.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!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">
  3. <head>
  4. <title>Keywords</title>
  5. <link rel="stylesheet" type="text/css" href="docbook-epub.css"/>
  6. <link rel="stylesheet" type="text/css" href="kawa.css"/>
  7. <script src="kawa-ebook.js" type="text/javascript"/>
  8. <meta name="generator" content="DocBook XSL-NS Stylesheets V1.79.1"/>
  9. <link rel="prev" href="Overall-Index.xhtml" title="Index"/>
  10. <link rel="next" href="Special-named-constants.xhtml" title="Special named constants"/>
  11. </head>
  12. <body>
  13. <header/>
  14. <section class="sect1" title="Keywords" epub:type="subchapter" id="Keywords">
  15. <div class="titlepage">
  16. <div>
  17. <div>
  18. <h2 class="title" style="clear: both">Keywords</h2>
  19. </div>
  20. </div>
  21. </div>
  22. <p>Keywords are similar to symbols.
  23. They are used mainly for specifying keyword arguments.
  24. </p>
  25. <p>Historically keywords have been self-evaluating (you did not need to
  26. quote them). This has changed: you must quote a keyword if you
  27. want a literal keyword value, and not quote it if it is used
  28. as a keyword argument.
  29. </p>
  30. <div class="literallayout">
  31. <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/>
  32.   | <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/>
  33. </p>
  34. </div>
  35. <p>The two syntaxes have the same meaning: The former is nicer-looking;
  36. the latter is more portable (and required if you use the
  37. <code class="literal">--r7rs</code> command-line flag).
  38. </p>
  39. <div class="blockquote">
  40. <blockquote class="blockquote">
  41. <p><span class="emphasis"><em>Details:</em></span>
  42. In r7rs and other Scheme standards the colon character
  43. does not have any special meaning, so <code class="literal">foo:</code> or <code class="literal">foo:bar</code>
  44. are just regular identifiers. Therefore some other Scheme variants
  45. that have keywords (including Guile and Racket) use the <code class="literal">#:</code> syntax.
  46. Kawa has some hacks so that <span class="emphasis"><em>most</em></span>
  47. standard Scheme programs that have colons in identifiers will work.
  48. However, for best compatibility, use the <code class="literal">--r7rs</code> command-line flag
  49. (which turns colon into a regular character in a symbol), and the
  50. <code class="literal">#:</code> syntax.
  51. </p>
  52. </blockquote>
  53. </div>
  54. <p>A keyword is a single token; therefore no whitespace is allowed between
  55. the <em class="replaceable"><code>identifier</code></em> and the colon or after the <code class="literal">#:</code>;
  56. these characters are not considered part of the name of the keyword.
  57. </p>
  58. <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>
  59. <div class="blockquote">
  60. <blockquote class="blockquote">
  61. <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>.
  62. </p>
  63. </blockquote>
  64. </div>
  65. <p class="synopsis" kind="Procedure"><span class="kind">Procedure</span><span class="ignore">: </span><a id="idm139667877549968" class="indexterm"/> <code class="function">keyword-&gt;string</code> <em class="replaceable"><code>keyword</code></em></p>
  66. <div class="blockquote">
  67. <blockquote class="blockquote">
  68. <p>Returns the name of <em class="replaceable"><code>keyword</code></em> as a string.
  69. The name does not include the final <code class="literal">#\:</code>.
  70. </p>
  71. </blockquote>
  72. </div>
  73. <p class="synopsis" kind="Procedure"><span class="kind">Procedure</span><span class="ignore">: </span><a id="idm139667877545680" class="indexterm"/> <code class="function">string-&gt;keyword</code> <em class="replaceable"><code>string</code></em></p>
  74. <div class="blockquote">
  75. <blockquote class="blockquote">
  76. <p>Returns the keyword whose name is <em class="replaceable"><code>string</code></em>.
  77. (The <em class="replaceable"><code>string</code></em> does not include a final <code class="literal">#\:</code>.)
  78. </p>
  79. </blockquote>
  80. </div>
  81. </section>
  82. <footer>
  83. <div class="navfooter">
  84. <p>
  85. Up: <a accesskey="u" href="Symbols-and-namespaces.xhtml">Symbols and namespaces</a></p>
  86. <p>
  87. Previous: <a accesskey="p" href="Namespaces.xhtml">Namespaces and compound symbols</a></p>
  88. <p>
  89. Next: <a accesskey="n" href="Special-named-constants.xhtml">Special named constants</a></p>
  90. </div>
  91. </footer>
  92. </body>
  93. </html>