Add `get-string-n' and `get-string-n!' for R6RS ports
[bpt/guile.git] / module / rnrs.scm
CommitLineData
2d56d2df
JG
1;;; rnrs.scm --- The R6RS composite library
2
b04f841d 3;; Copyright (C) 2010, 2011 Free Software Foundation, Inc.
2d56d2df
JG
4;;
5;; This library is free software; you can redistribute it and/or
6;; modify it under the terms of the GNU Lesser General Public
7;; License as published by the Free Software Foundation; either
8;; version 3 of the License, or (at your option) any later version.
9;;
10;; This library is distributed in the hope that it will be useful,
11;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13;; Lesser General Public License for more details.
14;;
15;; You should have received a copy of the GNU Lesser General Public
16;; License along with this library; if not, write to the Free Software
17;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18\f
19
20(library (rnrs (6))
21 (export ;; (rnrs arithmetic bitwise)
22
23 bitwise-not bitwise-and bitwise-ior bitwise-xor bitwise-if
24 bitwise-bit-count bitwise-length bitwise-first-bit-set
25 bitwise-bit-set? bitwise-copy-bit bitwise-bit-field
26 bitwise-copy-bit-field bitwise-arithmetic-shift
27 bitwise-arithmetic-shift-left bitwise-arithmetic-shift-right
28 bitwise-rotate-bit-field bitwise-reverse-bit-field
29
30 ;; (rnrs arithmetic fixnums)
31
32 fixnum? fixnum-width least-fixnum greatest-fixnum fx=? fx>? fx<? fx>=?
33 fx<=? fxzero? fxpositive? fxnegative? fxodd? fxeven? fxmax fxmin fx+
34 fx* fx- fxdiv-and-mod fxdiv fxmod fxdiv0-and-mod0 fxdiv0 fxmod0
35 fx+/carry fx-/carry fx*/carry fxnot fxand fxior fxxor fxif fxbit-count
36 fxlength fxfirst-bit-set fxbit-set? fxcopy-bit fxbit-field
37 fxcopy-bit-field fxarithmetic-shift fxarithmetic-shift-left
38 fxarithmetic-shift-right fxrotate-bit-field fxreverse-bit-field
39
40 ;; (rnrs arithmetic flonums)
41
42 flonum? real->flonum fl=? fl<? fl<=? fl>? fl>=? flinteger? flzero?
43 flpositive? flnegative? flodd? fleven? flfinite? flinfinite? flnan?
44 flmax flmin fl+ fl* fl- fl/ flabs fldiv-and-mod fldiv flmod
45 fldiv0-and-mod0 fldiv0 flmod0 flnumerator fldenominator flfloor
46 flceiling fltruncate flround flexp fllog flsin flcos fltan flacos
47 flasin flatan flsqrt flexpt &no-infinities
48 make-no-infinities-violation no-infinities-violation? &no-nans
49 make-no-nans-violation no-nans-violation? fixnum->flonum
50
51 ;; (rnrs base)
52
53 boolean? symbol? char? vector? null? pair? number? string? procedure?
54 define define-syntax syntax-rules lambda let let* let-values
b98d5a5a
JG
55 let*-values letrec letrec* begin quote lambda if set! cond case or
56 and not eqv? equal? eq? + - * / max min abs numerator denominator gcd
57 lcm floor ceiling truncate round rationalize real-part imag-part
2d56d2df
JG
58 make-rectangular angle div mod div-and-mod div0 mod0 div0-and-mod0
59 expt exact-integer-sqrt sqrt exp log sin cos tan asin acos atan
60 make-polar magnitude angle complex? real? rational? integer? exact?
b98d5a5a 61 inexact? real-valued? rational-valued? integer-valued? zero?
2d56d2df 62 positive? negative? odd? even? nan? finite? infinite? exact inexact =
b98d5a5a
JG
63 < > <= >= number->string string->number boolean=? cons car cdr caar
64 cadr cdar cddr caaar caadr cadar cdaar caddr cdadr cddar cdddr caaaar
65 caaadr caadar cadaar cdaaar cddaar cdadar cdaadr cadadr caaddr caddar
66 cadddr cdaddr cddadr cdddar cddddr list? list length append reverse
2d56d2df
JG
67 list-tail list-ref map for-each symbol->string string->symbol symbol=?
68 char->integer integer->char char=? char<? char>? char<=? char>=?
69 make-string string string-length string-ref string=? string<? string>?
70 string<=? string>=? substring string-append string->list list->string
71 string-for-each string-copy vector? make-vector vector vector-length
72 vector-ref vector-set! vector->list list->vector vector-fill!
73 vector-map vector-for-each error assertion-violation assert
74 call-with-current-continuation call/cc call-with-values dynamic-wind
75 values apply quasiquote unquote unquote-splicing let-syntax
76 letrec-syntax syntax-rules identifier-syntax
77
07d22c02 78 ;; (rnrs bytevectors)
2d56d2df
JG
79
80 endianness native-endianness bytevector? make-bytevector
81 bytevector-length bytevector=? bytevector-fill! bytevector-copy!
82 bytevector-copy uniform-array->bytevector bytevector-u8-ref
83 bytevector-s8-ref bytevector-u8-set! bytevector-s8-set!
84 bytevector->u8-list u8-list->bytevector bytevector-uint-ref
85 bytevector-uint-set! bytevector-sint-ref bytevector-sint-set!
86 bytevector->sint-list bytevector->uint-list uint-list->bytevector
87 sint-list->bytevector bytevector-u16-ref bytevector-s16-ref
88 bytevector-u16-set! bytevector-s16-set! bytevector-u16-native-ref
89 bytevector-s16-native-ref bytevector-u16-native-set!
90 bytevector-s16-native-set! bytevector-u32-ref bytevector-s32-ref
91 bytevector-u32-set! bytevector-s32-set! bytevector-u32-native-ref
92 bytevector-s32-native-ref bytevector-u32-native-set!
93 bytevector-s32-native-set! bytevector-u64-ref bytevector-s64-ref
94 bytevector-u64-set! bytevector-s64-set! bytevector-u64-native-ref
95 bytevector-s64-native-ref bytevector-u64-native-set!
96 bytevector-s64-native-set! bytevector-ieee-single-ref
97 bytevector-ieee-single-set! bytevector-ieee-single-native-ref
98 bytevector-ieee-single-native-set! bytevector-ieee-double-ref
99 bytevector-ieee-double-set! bytevector-ieee-double-native-ref
100 bytevector-ieee-double-native-set! string->utf8 string->utf16
101 string->utf32 utf8->string utf16->string utf32->string
102
103 ;; (rnrs conditions)
104
105 &condition condition simple-conditions condition? condition-predicate
106 condition-accessor define-condition-type &message
107 make-message-condition message-condition? condition-message &warning
108 make-warning warning? &serious make-serious-condition
109 serious-condition? &error make-error error? &violation make-violation
110 violation? &assertion make-assertion-violation assertion-violation?
111 &irritants make-irritants-condition irritants-condition?
112 condition-irritants &who make-who-condition who-condition?
113 condition-who &non-continuable make-non-continuable-violation
114 non-continuable-violation? &implementation-restriction
115 make-implementation-restriction-violation
116 implementation-restriction-violation? &lexical make-lexical-violation
117 lexical-violation? &syntax make-syntax-violation syntax-violation?
118 syntax-violation-form syntax-violation-subform &undefined
119 make-undefined-violation undefined-violation?
120
121 ;; (rnrs control)
122
123 when unless do case-lambda
124
125 ;; (rnrs enums)
126
127 make-enumeration enum-set-universe enum-set-indexer
128 enum-set-constructor enum-set->list enum-set-member? enum-set-subset?
129 enum-set=? enum-set-union enum-set-intersection enum-set-difference
130 enum-set-complement enum-set-projection define-enumeration
131
132 ;; (rnrs exceptions)
133
134 guard with-exception-handler raise raise-continuable
135
136 ;; (rnrs files)
137
138 file-exists? delete-file &i/o make-i/o-error i/o-error? &i/o-read
139 make-i/o-read-error i/o-read-error? &i/o-write make-i/o-write-error
140 i/o-write-error? &i/o-invalid-position
141 make-i/o-invalid-position-error i/o-invalid-position-error?
142 i/o-error-position &i/o-filename make-i/o-filename-error
143 i/o-filename-error? i/o-error-filename &i/o-file-protection
144 make-i/o-file-protection-error i/o-file-protection-error?
145 &i/o-file-is-read-only make-i/o-file-is-read-only-error
146 i/o-file-is-read-only-error? &i/o-file-already-exists
147 make-i/o-file-already-exists-error i/o-file-already-exists-error?
148 &i/o-file-does-not-exist make-i/o-file-does-not-exist-error
149 i/o-file-does-not-exist-error? &i/o-port make-i/o-port-error
150 i/o-port-error? i/o-error-port
151
152 ;; (rnrs hashtables)
153
154 make-eq-hashtable make-eqv-hashtable make-hashtable hashtable?
155 hashtable-size hashtable-ref hashtable-set! hashtable-delete!
156 hashtable-contains? hashtable-update! hashtable-copy hashtable-clear!
157 hashtable-keys hashtable-entries hashtable-equivalence-function
158 hashtable-hash-function hashtable-mutable? equal-hash string-hash
159 string-ci-hash symbol-hash
160
161 ;; (rnrs io ports)
162
a5484153
AR
163 file-options buffer-mode buffer-mode?
164 eol-style native-eol-style error-handling-mode
165 make-transcoder transcoder-codec native-transcoder
166 latin-1-codec utf-8-codec utf-16-codec
167
b04f841d
AW
168 eof-object? port? input-port? output-port? eof-object port-eof?
169 port-transcoder
2d56d2df 170 binary-port? transcoded-port port-position set-port-position!
a5484153
AR
171 port-has-port-position? port-has-set-port-position!?
172 close-port call-with-port
2d56d2df
JG
173 open-bytevector-input-port make-custom-binary-input-port get-u8
174 lookahead-u8 get-bytevector-n get-bytevector-n! get-bytevector-some
175 get-bytevector-all open-bytevector-output-port
176 make-custom-binary-output-port put-u8 put-bytevector
c3993330 177 open-string-input-port open-string-output-port
a5484153
AR
178 call-with-bytevector-output-port
179 call-with-string-output-port
180 latin-1-codec utf-8-codec utf-16-codec
181 open-file-input-port open-file-output-port
182 make-custom-textual-output-port
183 call-with-string-output-port
184 flush-output-port put-string
a6c377f7
AR
185 get-char get-datum get-line get-string-all get-string-n get-string-n!
186 lookahead-char
a5484153
AR
187 put-char put-datum put-string
188 standard-input-port standard-output-port standard-error-port
189
2d56d2df
JG
190 ;; (rnrs io simple)
191
192 call-with-input-file call-with-output-file current-input-port
193 current-output-port current-error-port with-input-from-file
194 with-output-to-file open-input-file open-output-file close-input-port
195 close-output-port read-char peek-char read write-char newline display
196 write
197
198 ;; (rnrs lists)
199
200 find for-all exists filter partition fold-left fold-right remp remove
201 remv remq memp member memv memq assp assoc assv assq cons*
202
203 ;; (rnrs programs)
204
205 command-line exit
206
207 ;; (rnrs records inspection)
208
209 record? record-rtd record-type-name record-type-parent
210 record-type-uid record-type-generative? record-type-sealed?
211 record-type-opaque? record-type-field-names record-field-mutable?
212
213 ;; (rnrs records procedural)
214
215 make-record-type-descriptor record-type-descriptor?
216 make-record-constructor-descriptor record-constructor record-predicate
217 record-accessor record-mutator
218
219 ;; (rnrs records syntactic)
220
221 define-record-type record-type-descriptor
222 record-constructor-descriptor
223
224 ;; (rnrs sorting)
225
226 list-sort vector-sort vector-sort!
227
228 ;; (rnrs syntax-case)
229
61bac799
AW
230 make-variable-transformer syntax
231 ;; Until the deprecated support for a unified modules and
232 ;; bindings namespace is removed, we need to manually resolve
233 ;; a conflict between two bindings: that of the (rnrs
234 ;; syntax-case) module, and the imported `syntax-case'
235 ;; binding. We do so here and below by renaming the macro
236 ;; import.
237 (rename (syntax-case-hack syntax-case))
238 identifier? bound-identifier=? free-identifier=?
239 syntax->datum datum->syntax generate-temporaries with-syntax
240 quasisyntax unsyntax unsyntax-splicing syntax-violation
a2e0b126
AR
241
242 ;; (rnrs unicode)
243
244 char-upcase char-downcase char-titlecase char-foldcase
245 char-ci=? char-ci<? char-ci>? char-ci<=? char-ci>=?
246 char-alphabetic? char-numeric? char-whitespace? char-upper-case?
247 char-lower-case? char-title-case? char-general-category
248 string-upcase string-downcase string-titlecase string-foldcase
249 string-ci=? string-ci<? string-ci>? string-ci<=? string-ci>=?
250 string-normalize-nfd string-normalize-nfkd string-normalize-nfc
251 string-normalize-nfkc)
2d56d2df
JG
252
253 (import (rnrs arithmetic bitwise (6))
254 (rnrs arithmetic fixnums (6))
255 (rnrs arithmetic flonums (6))
256 (rnrs base (6))
257
c08adae4
AW
258 (rnrs bytevectors (6))
259
2d56d2df
JG
260 (rnrs conditions (6))
261 (rnrs control (6))
262 (rnrs enums (6))
263 (rnrs exceptions (6))
8d10ccae 264
50851f1d 265 (rnrs files (6))
8d10ccae 266
2d56d2df
JG
267 (rnrs hashtables (6))
268
c08adae4 269 (rnrs io ports (6))
2d56d2df
JG
270
271 (rnrs io simple (6))
272 (rnrs lists (6))
273 (rnrs programs (6))
274 (rnrs records inspection (6))
275 (rnrs records procedural (6))
276 (rnrs records syntactic (6))
277 (rnrs sorting (6))
61bac799
AW
278 ;; See note above on exporting syntax-case.
279 (rename (rnrs syntax-case (6))
280 (syntax-case syntax-case-hack))
a2e0b126 281 (rnrs unicode (6))))