safe-r5rs.scm 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. ;;;; Copyright (C) 2000, 2001, 2004, 2006 Free Software Foundation, Inc.
  2. ;;;;
  3. ;;;; This library is free software; you can redistribute it and/or
  4. ;;;; modify it under the terms of the GNU Lesser General Public
  5. ;;;; License as published by the Free Software Foundation; either
  6. ;;;; version 2.1 of the License, or (at your option) any later version.
  7. ;;;;
  8. ;;;; This library is distributed in the hope that it will be useful,
  9. ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. ;;;; Lesser General Public License for more details.
  12. ;;;;
  13. ;;;; You should have received a copy of the GNU Lesser General Public
  14. ;;;; License along with this library; if not, write to the Free Software
  15. ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  16. ;;;;
  17. ;;;; Safe subset of R5RS bindings
  18. (define-module (ice-9 safe-r5rs)
  19. :re-export (eqv? eq? equal?
  20. number? complex? real? rational? integer?
  21. exact? inexact?
  22. = < > <= >=
  23. zero? positive? negative? odd? even?
  24. max min
  25. + * - /
  26. abs
  27. quotient remainder modulo
  28. gcd lcm
  29. numerator denominator
  30. rationalize
  31. floor ceiling truncate round
  32. exp log sin cos tan asin acos atan
  33. sqrt
  34. expt
  35. make-rectangular make-polar real-part imag-part magnitude angle
  36. exact->inexact inexact->exact
  37. number->string string->number
  38. boolean?
  39. not
  40. pair?
  41. cons car cdr
  42. set-car! set-cdr!
  43. caar cadr cdar cddr
  44. caaar caadr cadar caddr cdaar cdadr cddar cdddr
  45. caaaar caaadr caadar caaddr cadaar cadadr caddar cadddr
  46. cdaaar cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr
  47. null?
  48. list?
  49. list
  50. length
  51. append
  52. reverse
  53. list-tail list-ref
  54. memq memv member
  55. assq assv assoc
  56. symbol?
  57. symbol->string string->symbol
  58. char?
  59. char=? char<? char>? char<=? char>=?
  60. char-ci=? char-ci<? char-ci>? char-ci<=? char-ci>=?
  61. char-alphabetic? char-numeric? char-whitespace?
  62. char-upper-case? char-lower-case?
  63. char->integer integer->char
  64. char-upcase
  65. char-downcase
  66. string?
  67. make-string
  68. string
  69. string-length
  70. string-ref string-set!
  71. string=? string-ci=?
  72. string<? string>? string<=? string>=?
  73. string-ci<? string-ci>? string-ci<=? string-ci>=?
  74. substring
  75. string-length
  76. string-append
  77. string->list list->string
  78. string-copy string-fill!
  79. vector?
  80. make-vector
  81. vector
  82. vector-length
  83. vector-ref vector-set!
  84. vector->list list->vector
  85. vector-fill!
  86. procedure?
  87. apply
  88. map
  89. for-each
  90. force
  91. call-with-current-continuation
  92. values
  93. call-with-values
  94. dynamic-wind
  95. eval
  96. input-port? output-port?
  97. current-input-port current-output-port
  98. read
  99. read-char
  100. peek-char
  101. eof-object?
  102. char-ready?
  103. write
  104. display
  105. newline
  106. write-char
  107. ;;transcript-on
  108. ;;transcript-off
  109. )
  110. :export (null-environment))
  111. (define null-interface (resolve-interface '(ice-9 null)))
  112. (module-use! %module-public-interface null-interface)
  113. (define (null-environment n)
  114. (if (not (= n 5))
  115. (scm-error 'misc-error 'null-environment
  116. "~A is not a valid version"
  117. (list n)
  118. '()))
  119. ;; Note that we need to create a *fresh* interface
  120. (let ((interface (make-module 31)))
  121. (set-module-kind! interface 'interface)
  122. (module-use! interface null-interface)
  123. interface))