r7rs.texi 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. @c -*-texinfo-*-
  2. @c This is part of the GNU Guile Reference Manual.
  3. @c Copyright (C) 2010, 2011, 2012, 2013,
  4. @c 2014, 2019 Free Software Foundation, Inc.
  5. @c See the file guile.texi for copying conditions.
  6. @node R7RS Support
  7. @section R7RS Support
  8. @cindex R7RS
  9. The @uref{https://small.r7rs.org/,R7RS} standard is essentially R5RS
  10. (directly supported by Guile), plus a module facility, plus an
  11. organization of bindings into a standard set of modules.
  12. Happily, the syntax for R7RS modules was chosen to be compatible with
  13. R6RS, and so Guile's documentation there applies. @xref{R6RS
  14. Libraries}, for more information on how to define R6RS libraries, and
  15. their integration with Guile modules. @xref{Library Usage}, also.
  16. @menu
  17. * R7RS Incompatibilities:: Guile mostly implements R7RS.
  18. * R7RS Standard Libraries:: Modules defined by the R7RS.
  19. @end menu
  20. @node R7RS Incompatibilities
  21. @subsection Incompatibilities with the R7RS
  22. As the R7RS is a much less ambitious standard than the R6RS
  23. (@pxref{Guile and Scheme}), it is very easy for Guile to support. As
  24. such, Guile is a fully conforming implementation of R7RS, with the
  25. exception of the occasional bug and a couple of unimplemented features:
  26. @itemize
  27. @item
  28. @cindex datum labels
  29. The R7RS specifies a syntax for reading circular data structures using
  30. @dfn{datum labels}, such as @code{#0=(1 2 3 . #0#)}. Guile's reader
  31. does not support this syntax currently;
  32. @url{https://bugs.gnu.org/38236}.
  33. @item
  34. As with R6RS, a number of lexical features of R7RS conflict with Guile's
  35. historical syntax. In addition to @code{r6rs-hex-escapes} and
  36. @code{hungry-eol-escapes} (@pxref{R6RS Incompatibilities}), the
  37. @code{r7rs-symbols} reader feature needs to be explicitly enabled.
  38. @end itemize
  39. Guile exposes a procedure in the root module to choose R7RS defaults
  40. over Guile's historical defaults.
  41. @deffn {Scheme Procedure} install-r7rs!
  42. Alter Guile's default settings to better conform to the R7RS.
  43. While Guile's defaults may evolve over time, the current changes that
  44. this procedure imposes are to add @code{.sls} and @code{.guile.sls} to
  45. the set of supported @code{%load-extensions}, to better support R7RS
  46. conventions. @xref{Load Paths}. @code{install-r7rs!} will also enable
  47. the reader options mentioned above.
  48. @end deffn
  49. Finally, note that the @code{--r7rs} command-line argument will call
  50. @code{install-r7rs!} before calling user code. R7RS users probably want
  51. to pass this argument to their Guile.
  52. @node R7RS Standard Libraries
  53. @subsection R7RS Standard Libraries
  54. The R7RS organizes the definitions from R5RS into modules, and also adds
  55. a few new definitions.
  56. We do not attempt to document these libraries fully here, as unlike
  57. R6RS, there are few new definitions in R7RS relative to R5RS. Most of
  58. their functionality is already in Guile's standard environment. Again,
  59. the expectation is that most Guile users will use the well-known and
  60. well-documented Guile modules; these R7RS libraries are mostly useful to
  61. users who want to port their code to other R7RS systems.
  62. As a brief overview, we note that the libraries defined by the R7RS are
  63. as follows:
  64. @table @code
  65. @item (scheme base)
  66. The core functions, mostly corresponding to R5RS minus the elements
  67. listed separately below, but plus SRFI-34 error handling
  68. (@pxref{SRFI-34}), bytevectors and bytevector ports
  69. (@pxref{Bytevectors}), and some miscellaneous other new procedures.
  70. @item (scheme case-lambda)
  71. @code{case-lambda}.
  72. @item (scheme char)
  73. Converting strings and characters to upper or lower case, predicates for
  74. if a characer is numeric, and so on.
  75. @item (scheme complex)
  76. Constructors and accessors for complex numbers.
  77. @item (scheme cxr)
  78. @code{cddr}, @code{cadadr}, and all that.
  79. @item (scheme eval)
  80. @code{eval}, but also an @code{environment} routine allowing a user to
  81. specify an environment using a module import set.
  82. @item (scheme file)
  83. @code{call-with-input-file} and so on.
  84. @item (scheme inexact)
  85. Routines that operate on inexact numbers: @code{sin}, @code{finite?},
  86. and so on.
  87. @item (scheme lazy)
  88. Promises.
  89. @item (scheme load)
  90. The @code{load} procedure.
  91. @item (scheme process-context)
  92. Environment variables. @xref{SRFI-98}. Also, @code{commmand-line},
  93. @code{emergency-exit} (like Guile's @code{primitive-_exit}), and
  94. @code{exit}.
  95. @item (scheme r5rs)
  96. The precise set of bindings exported by @code{r5rs}, but without
  97. @code{transcript-off} / @code{transcript-on}, and also with the
  98. auxiliary syntax definitions like @code{_} or @code{else}. @xref{Syntax
  99. Rules}, for more on auxiliary syntax.
  100. @item (scheme read)
  101. The @code{read} procedure.
  102. @item (scheme repl)
  103. The @code{interaction-environment} procedure.
  104. @item (scheme time)
  105. @code{current-second}, as well as @code{current-jiffy} and
  106. @code{jiffies-per-second}. Guile uses the term ``internal time unit''
  107. for what R7RS calls ``jiffies''.
  108. @item (scheme write)
  109. @code{display}, @code{write}, as well as @code{write-shared} and
  110. @code{write-simple}.
  111. @end table
  112. For complete documentation, we advise the interested user to consult the
  113. R7RS directly (@pxref{R7RS,,, r7rs, The Revised^7 Report on the
  114. Algorithmic Language Scheme}).
  115. @c Local Variables:
  116. @c TeX-master: "guile.texi"
  117. @c End: