Scheme-types-in-Java.xhtml 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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>Scheme types in Java</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="Array-operations.xhtml" title="Using Java Arrays"/>
  11. </head>
  12. <body>
  13. <header/>
  14. <section class="sect1" title="Scheme types in Java" epub:type="subchapter" id="Scheme-types-in-Java">
  15. <div class="titlepage">
  16. <div>
  17. <div>
  18. <h2 class="title" style="clear: both">Scheme types in Java</h2>
  19. </div>
  20. </div>
  21. </div>
  22. <p>All Scheme values are implemented by sub-classes of ‘<code class="literal">java.lang.Object</code>’.
  23. </p>
  24. <p>Scheme symbols are implemented using <code class="literal">java.lang.String</code>.
  25. (Don’t be confused by the fact the Scheme sybols are represented
  26. using Java Strings, while Scheme strings are represented by
  27. <code class="literal">gnu.lists.FString</code>. It is just that the semantics of Java strings
  28. match Scheme symbols, but do not match mutable Scheme strings.)
  29. Interned symbols are presented as interned Strings.
  30. (Note that with JDK 1.1 string literals are automatically interned.)
  31. </p>
  32. <p>Scheme integers are implemented by <code class="literal">gnu.math.IntNum</code>.
  33. Use the make static function to create a new IntNum from an int or a long.
  34. Use the intValue or longValue methods to get the int or long value of
  35. an IntNum.
  36. </p>
  37. <p>A Scheme "flonum" is implemented by <code class="literal">gnu.math.DFloNum</code>.
  38. </p>
  39. <p>A Scheme pair is implemented by <code class="literal">gnu.lists.Pair</code>.
  40. </p>
  41. <p>A Scheme vector is implemented by <code class="literal">gnu.lists.FVectror</code>.
  42. </p>
  43. <p>Scheme characters are implemented using <code class="literal">gnu.text.Char</code>.
  44. </p>
  45. <p>Scheme strings are implemented using <code class="literal">gnu.lists.FString</code>.
  46. </p>
  47. <p>Scheme procedures are all sub-classes of <code class="literal">gnu.mapping.Procedure</code>.
  48. The "action" of a ‘<code class="literal">Procedure</code>’ is invoked by using one of
  49. the ‘<code class="literal">apply*</code>’ methods: ‘<code class="literal">apply0</code>’, ‘<code class="literal">apply1</code>’,
  50. ‘<code class="literal">apply2</code>’, ‘<code class="literal">apply3</code>’, ‘<code class="literal">apply4</code>’, or ‘<code class="literal">applyN</code>’.
  51. Various sub-class of ‘<code class="literal">Procedure</code>’ provide defaults
  52. for the various ‘<code class="literal">apply*</code>’ methods. For example,
  53. a ‘<code class="literal">Procedure2</code>’ is used by 2-argument procedures.
  54. The ‘<code class="literal">Procedure2</code>’ class provides implementations of all
  55. the ‘<code class="literal">apply*</code>’ methods <span class="emphasis"><em>except</em></span> ‘<code class="literal">apply2</code>’,
  56. which must be provided by any class that extends <code class="literal">Procedure2</code>.
  57. </p>
  58. </section>
  59. <footer>
  60. <div class="navfooter">
  61. <p>
  62. Up: <a accesskey="u" href="Objects-Classes-and-Modules.xhtml">Object, Classes and Modules</a></p>
  63. <p>
  64. Previous: <a accesskey="p" href="Mangling.xhtml">Mapping Scheme names to Java names</a></p>
  65. <p>
  66. Next: <a accesskey="n" href="Array-operations.xhtml">Using Java Arrays</a></p>
  67. </div>
  68. </footer>
  69. </body>
  70. </html>