Update copyright date of manual, and a small fix
[bpt/guile.git] / doc / ref / r6rs.texi
1 @c -*-texinfo-*-
2 @c This is part of the GNU Guile Reference Manual.
3 @c Copyright (C) 2010, 2011
4 @c Free Software Foundation, Inc.
5 @c See the file guile.texi for copying conditions.
6
7 @node R6RS Support
8 @section R6RS Support
9 @cindex R6RS
10
11 @xref{R6RS Libraries}, for more information on how to define R6RS libraries, and
12 their integration with Guile modules.
13
14 @menu
15 * R6RS Incompatibilities:: Guile mostly implements R6RS.
16 * R6RS Standard Libraries:: Modules defined by the R6RS.
17 @end menu
18
19 @node R6RS Incompatibilities
20 @subsection Incompatibilities with the R6RS
21
22 There are some incompatibilities between Guile and the R6RS. Some of
23 them are intentional, some of them are bugs, and some are simply
24 unimplemented features. Please let the Guile developers know if you
25 find one that is not on this list.
26
27 @itemize
28 @item
29 The R6RS specifies many situations in which a conforming implementation
30 must signal a specific error. Guile doesn't really care about that too
31 much---if a correct R6RS program would not hit that error, we don't
32 bother checking for it.
33
34 @item
35 Multiple @code{library} forms in one file are not yet supported. This
36 is because the expansion of @code{library} sets the current module, but
37 does not restore it. This is a bug.
38
39 @item
40 R6RS unicode escapes within strings are disabled by default, because
41 they conflict with Guile's already-existing escapes. R6RS behavior can
42 be turned on via a reader option. @xref{String Syntax}, for more
43 information.
44
45 @item
46 A @code{set!} to a variable transformer may only expand to an
47 expression, not a definition---even if the original @code{set!}
48 expression was in definition context.
49
50 @item
51 Instead of using the algorithm detailed in chapter 10 of the R6RS,
52 expansion of toplevel forms happens sequentially.
53
54 For example, while the expansion of the following set of recursive
55 nested definitions does do the correct thing:
56
57 @example
58 (let ()
59 (define even?
60 (lambda (x)
61 (or (= x 0) (odd? (- x 1)))))
62 (define-syntax odd?
63 (syntax-rules ()
64 ((odd? x) (not (even? x)))))
65 (even? 10))
66 @result{} #t
67 @end example
68
69 @noindent
70 The same definitions at the toplevel do not:
71
72 @example
73 (begin
74 (define even?
75 (lambda (x)
76 (or (= x 0) (odd? (- x 1)))))
77 (define-syntax odd?
78 (syntax-rules ()
79 ((odd? x) (not (even? x)))))
80 (even? 10))
81 <unnamed port>:4:18: In procedure even?:
82 <unnamed port>:4:18: Wrong type to apply: #<syntax-transformer odd?>
83 @end example
84
85 This is because when expanding the right-hand-side of @code{even?}, the
86 reference to @code{odd?} is not yet marked as a syntax transformer, so
87 it is assumed to be a function.
88
89 While it is likely that we can fix the case of toplevel forms nested in
90 a @code{begin} or a @code{library} form, a fix for toplevel programs
91 seems trickier to implement in a backward-compatible way. Suggestions
92 and/or patches would be appreciated.
93
94 @item
95 The @code{(rnrs io ports)} module is mostly unimplemented. Work is
96 ongoing to fix this.
97 @end itemize
98
99 @node R6RS Standard Libraries
100 @subsection R6RS Standard Libraries
101
102 In contrast with earlier versions of the Revised Report, the R6RS
103 organizes the procedures and syntactic forms required of conforming
104 implementations into a set of ``standard libraries'' which can be
105 imported as necessary by user programs and libraries. Here we briefly
106 list the libraries that have been implemented for Guile.
107
108 We do not attempt to document these libraries fully here, as most of
109 their functionality is already available in Guile itself. The
110 expectation is that most Guile users will use the well-known and
111 well-documented Guile modules. These R6RS libraries are mostly useful
112 to users who want to port their code to other R6RS systems.
113
114 The documentation in the following sections reproduces some of the
115 content of the library section of the Report, but is mostly intended to
116 provide supplementary information about Guile's implementation of the
117 R6RS standard libraries. For complete documentation, design rationales
118 and further examples, we advise you to consult the ``Standard
119 Libraries'' section of the Report (@pxref{Standard Libraries,
120 R6RS Standard Libraries,, r6rs, The Revised^6 Report on the Algorithmic
121 Language Scheme}).
122
123 @menu
124 * Library Usage:: What to know about Guile's library support.
125 * rnrs base:: The base library.
126 * rnrs unicode:: Access to Unicode operations.
127 * rnrs bytevectors:: Functions for working with binary data.
128 * rnrs lists:: List utilities.
129 * rnrs sorting:: Sorting for lists and vectors.
130 * rnrs control:: Additional control structures.
131
132 * R6RS Records:: A note about R6RS records.
133 * rnrs records syntactic:: Syntactic API for R6RS records.
134 * rnrs records procedural:: Procedural API for R6RS records.
135 * rnrs records inspection:: Reflection on R6RS records.
136
137 * rnrs exceptions:: Handling exceptional situations.
138 * rnrs conditions:: Data structures for exceptions.
139
140 * I/O Conditions:: Predefined I/O error types.
141 * rnrs io ports:: Support for port-based I/O.
142 * rnrs io simple:: High-level I/O API.
143
144 * rnrs files:: Functions for working with files.
145 * rnrs programs:: Functions for working with processes.
146 * rnrs arithmetic fixnums:: Fixed-precision arithmetic operations.
147 * rnrs arithmetic flonums:: Floating-point arithmetic operations.
148 * rnrs arithmetic bitwise:: Exact bitwise arithmetic operations.
149 * rnrs syntax-case:: Support for `syntax-case' macros.
150 * rnrs hashtables:: Hashtables.
151 * rnrs enums:: Enumerations.
152 * rnrs:: The composite library.
153 * rnrs eval:: Support for on-the-fly evaluation.
154 * rnrs mutable-pairs:: Support for mutable pairs.
155 * rnrs mutable-strings:: Support for mutable strings.
156 * rnrs r5rs:: Compatibility layer for R5RS Scheme.
157
158 @end menu
159
160 @node Library Usage
161 @subsubsection Library Usage
162
163 Guile implements the R6RS `library' form as a transformation to a native
164 Guile module definition. As a consequence of this, all of the libraries
165 described in the following subsections, in addition to being available
166 for use by R6RS libraries and top-level programs, can also be imported
167 as if they were normal Guile modules---via a @code{use-modules} form,
168 say. For example, the R6RS ``composite'' library can be imported by:
169
170 @lisp
171 (import (rnrs (6)))
172 @end lisp
173
174 @lisp
175 (use-modules ((rnrs) :version (6)))
176 @end lisp
177
178 For more information on Guile's library implementation, see
179 (@pxref{R6RS Libraries}).
180
181 @node rnrs base
182 @subsubsection rnrs base
183
184 The @code{(rnrs base (6))} library exports the procedures and syntactic
185 forms described in the main section of the Report
186 (@pxref{Base library, R6RS Base library,, r6rs,
187 The Revised^6 Report on the Algorithmic Language Scheme}). They are
188 grouped below by the existing manual sections to which they correspond.
189
190 @deffn {Scheme Procedure} boolean? obj
191 @deffnx {Scheme Procedure} not x
192 @xref{Booleans}, for documentation.
193 @end deffn
194
195 @deffn {Scheme Procedure} symbol? obj
196 @deffnx {Scheme Procedure} symbol->string sym
197 @deffnx {Scheme Procedure} string->symbol str
198 @xref{Symbol Primitives}, for documentation.
199 @end deffn
200
201 @deffn {Scheme Procedure} char? obj
202 @deffnx {Scheme Procedure} char=?
203 @deffnx {Scheme Procedure} char<?
204 @deffnx {Scheme Procedure} char>?
205 @deffnx {Scheme Procedure} char<=?
206 @deffnx {Scheme Procedure} char>=?
207 @deffnx {Scheme Procedure} integer->char n
208 @deffnx {Scheme Procedure} char->integer chr
209 @xref{Characters}, for documentation.
210 @end deffn
211
212 @deffn {Scheme Procedure} list? x
213 @deffnx {Scheme Procedure} null? x
214 @xref{List Predicates}, for documentation.
215 @end deffn
216
217 @deffn {Scheme Procedure} pair? x
218 @deffnx {Scheme Procedure} cons x y
219 @deffnx {Scheme Procedure} car pair
220 @deffnx {Scheme Procedure} cdr pair
221 @deffnx {Scheme Procedure} caar pair
222 @deffnx {Scheme Procedure} cadr pair
223 @deffnx {Scheme Procedure} cdar pair
224 @deffnx {Scheme Procedure} cddr pair
225 @deffnx {Scheme Procedure} caaar pair
226 @deffnx {Scheme Procedure} caadr pair
227 @deffnx {Scheme Procedure} cadar pair
228 @deffnx {Scheme Procedure} cdaar pair
229 @deffnx {Scheme Procedure} caddr pair
230 @deffnx {Scheme Procedure} cdadr pair
231 @deffnx {Scheme Procedure} cddar pair
232 @deffnx {Scheme Procedure} cdddr pair
233 @deffnx {Scheme Procedure} caaaar pair
234 @deffnx {Scheme Procedure} caaadr pair
235 @deffnx {Scheme Procedure} caadar pair
236 @deffnx {Scheme Procedure} cadaar pair
237 @deffnx {Scheme Procedure} cdaaar pair
238 @deffnx {Scheme Procedure} cddaar pair
239 @deffnx {Scheme Procedure} cdadar pair
240 @deffnx {Scheme Procedure} cdaadr pair
241 @deffnx {Scheme Procedure} cadadr pair
242 @deffnx {Scheme Procedure} caaddr pair
243 @deffnx {Scheme Procedure} caddar pair
244 @deffnx {Scheme Procedure} cadddr pair
245 @deffnx {Scheme Procedure} cdaddr pair
246 @deffnx {Scheme Procedure} cddadr pair
247 @deffnx {Scheme Procedure} cdddar pair
248 @deffnx {Scheme Procedure} cddddr pair
249 @xref{Pairs}, for documentation.
250 @end deffn
251
252 @deffn {Scheme Procedure} number? obj
253 @xref{Numerical Tower}, for documentation.
254 @end deffn
255
256 @deffn {Scheme Procedure} string? obj
257 @xref{String Predicates}, for documentation.
258 @end deffn
259
260 @deffn {Scheme Procedure} procedure? obj
261 @xref{Procedure Properties}, for documentation.
262 @end deffn
263
264 @deffn {Scheme Syntax} define name value
265 @deffnx {Scheme Syntax} set! variable-name value
266 @xref{Definition}, for documentation.
267 @end deffn
268
269 @deffn {Scheme Syntax} define-syntax keyword expression
270 @deffnx {Scheme Syntax} let-syntax ((keyword transformer) ...) exp ...
271 @deffnx {Scheme Syntax} letrec-syntax ((keyword transformer) ...) exp ...
272 @xref{Defining Macros}, for documentation.
273 @end deffn
274
275 @deffn {Scheme Syntax} identifier-syntax exp
276 @xref{Identifier Macros}, for documentation.
277 @end deffn
278
279 @deffn {Scheme Syntax} syntax-rules literals (pattern template) ...
280 @xref{Syntax Rules}, for documentation.
281 @end deffn
282
283 @deffn {Scheme Syntax} lambda formals body
284 @xref{Lambda}, for documentation.
285 @end deffn
286
287 @deffn {Scheme Syntax} let bindings body
288 @deffnx {Scheme Syntax} let* bindings body
289 @deffnx {Scheme Syntax} letrec bindings body
290 @deffnx {Scheme Syntax} letrec* bindings body
291 @xref{Local Bindings}, for documentation.
292 @end deffn
293
294 @deffn {Scheme Syntax} let-values bindings body
295 @deffnx {Scheme Syntax} let*-values bindings body
296 @xref{SRFI-11}, for documentation.
297 @end deffn
298
299 @deffn {Scheme Syntax} begin expr1 expr2 ...
300 @xref{begin}, for documentation.
301 @end deffn
302
303 @deffn {Scheme Syntax} quote expr
304 @deffnx {Scheme Syntax} quasiquote expr
305 @deffnx {Scheme Syntax} unquote expr
306 @deffnx {Scheme Syntax} unquote-splicing expr
307 @xref{Expression Syntax}, for documentation.
308 @end deffn
309
310 @deffn {Scheme Syntax} if test consequence [alternate]
311 @deffnx {Scheme Syntax} cond clause1 clause2 ...
312 @deffnx {Scheme Syntax} case key clause1 clause2 ...
313 @xref{if cond case}, for documentation.
314 @end deffn
315
316 @deffn {Scheme Syntax} and expr ...
317 @deffnx {Scheme Syntax} or expr ...
318 @xref{and or}, for documentation.
319 @end deffn
320
321 @deffn {Scheme Procedure} eq? x y
322 @deffnx {Scheme Procedure} eqv? x y
323 @deffnx {Scheme Procedure} equal? x y
324 @deffnx {Scheme Procedure} symbol=? symbol1 symbol2 ...
325 @xref{Equality}, for documentation.
326
327 @code{symbol=?} is identical to @code{eq?}.
328 @end deffn
329
330 @deffn {Scheme Procedure} complex? z
331 @xref{Complex Numbers}, for documentation.
332 @end deffn
333
334 @deffn {Scheme Procedure} real-part z
335 @deffnx {Scheme Procedure} imag-part z
336 @deffnx {Scheme Procedure} make-rectangular real_part imaginary_part
337 @deffnx {Scheme Procedure} make-polar x y
338 @deffnx {Scheme Procedure} magnitude z
339 @deffnx {Scheme Procedure} angle z
340 @xref{Complex}, for documentation.
341 @end deffn
342
343 @deffn {Scheme Procedure} sqrt z
344 @deffnx {Scheme Procedure} exp z
345 @deffnx {Scheme Procedure} expt z1 z2
346 @deffnx {Scheme Procedure} log z
347 @deffnx {Scheme Procedure} sin z
348 @deffnx {Scheme Procedure} cos z
349 @deffnx {Scheme Procedure} tan z
350 @deffnx {Scheme Procedure} asin z
351 @deffnx {Scheme Procedure} acos z
352 @deffnx {Scheme Procedure} atan z
353 @xref{Scientific}, for documentation.
354 @end deffn
355
356 @deffn {Scheme Procedure} real? x
357 @deffnx {Scheme Procedure} rational? x
358 @deffnx {Scheme Procedure} nan? x
359 @deffnx {Scheme Procedure} numerator x
360 @deffnx {Scheme Procedure} denominator x
361 @deffnx {Scheme Procedure} rationalize x eps
362 @xref{Reals and Rationals}, for documentation.
363 @end deffn
364
365 @deffn {Scheme Procedure} exact? x
366 @deffnx {Scheme Procedure} inexact? x
367 @deffnx {Scheme Procedure} exact z
368 @deffnx {Scheme Procedure} inexact z
369 @xref{Exactness}, for documentation. The @code{exact} and
370 @code{inexact} procedures are identical to the @code{inexact->exact} and
371 @code{exact->inexact} procedures provided by Guile's code library.
372 @end deffn
373
374 @deffn {Scheme Procedure} integer? x
375 @xref{Integers}, for documentation.
376 @end deffn
377
378 @deffn {Scheme Procedure} odd? n
379 @deffnx {Scheme Procedure} even? n
380 @deffnx {Scheme Procedure} gcd x ...
381 @deffnx {Scheme Procedure} lcm x ...
382 @xref{Integer Operations}, for documentation.
383 @end deffn
384
385 @deffn {Scheme Procedure} =
386 @deffnx {Scheme Procedure} <
387 @deffnx {Scheme Procedure} >
388 @deffnx {Scheme Procedure} <=
389 @deffnx {Scheme Procedure} >=
390 @deffnx {Scheme Procedure} zero? x
391 @deffnx {Scheme Procedure} positive? x
392 @deffnx {Scheme Procedure} negative? x
393 @xref{Comparison}, for documentation.
394 @end deffn
395
396 @deffn {Scheme Procedure} for-each f lst1 lst2 ...
397 @xref{SRFI-1 Fold and Map}, for documentation.
398 @end deffn
399
400 @deffn {Scheme Procedure} list elem1 ... elemN
401 @xref{List Constructors}, for documentation.
402 @end deffn
403
404 @deffn {Scheme Procedure} length lst
405 @deffnx {Scheme Procedure} list-ref lst k
406 @deffnx {Scheme Procedure} list-tail lst k
407 @xref{List Selection}, for documentation.
408 @end deffn
409
410 @deffn {Scheme Procedure} append lst1 ... lstN
411 @deffnx {Scheme Procedure} reverse lst
412 @xref{Append/Reverse}, for documentation.
413 @end deffn
414
415 @deffn {Scheme Procedure} number->string n [radix]
416 @deffnx {Scheme Procedure} string->number str [radix]
417 @xref{Conversion}, for documentation.
418 @end deffn
419
420 @deffn {Scheme Procedure} string char ...
421 @deffnx {Scheme Procedure} make-string k [chr]
422 @deffnx {Scheme Procedure} list->string lst
423 @xref{String Constructors}, for documentation.
424 @end deffn
425
426 @deffn {Scheme Procedure} string->list str [start [end]]
427 @xref{List/String Conversion}, for documentation.
428 @end deffn
429
430 @deffn {Scheme Procedure} string-length str
431 @deffnx {Scheme Procedure} string-ref str k
432 @deffnx {Scheme Procedure} string-copy str [start [end]]
433 @deffnx {Scheme Procedure} substring str start [end]
434 @xref{String Selection}, for documentation.
435 @end deffn
436
437 @deffn {Scheme Procedure} string=? [s1 [s2 . rest]]
438 @deffnx {Scheme Procedure} string<? [s1 [s2 . rest]]
439 @deffnx {Scheme Procedure} string>? [s1 [s2 . rest]]
440 @deffnx {Scheme Procedure} string<=? [s1 [s2 . rest]]
441 @deffnx {Scheme Procedure} string>=? [s1 [s2 . rest]]
442 @xref{String Comparison}, for documentation.
443 @end deffn
444
445 @deffn {Scheme Procedure} string-append . args
446 @xref{Reversing and Appending Strings}, for documentation.
447 @end deffn
448
449 @deffn {Scheme Procedure} string-for-each proc s [start [end]]
450 @xref{Mapping Folding and Unfolding}, for documentation.
451 @end deffn
452
453 @deffn {Scheme Procedure} + z1 ...
454 @deffnx {Scheme Procedure} - z1 z2 ...
455 @deffnx {Scheme Procedure} * z1 ...
456 @deffnx {Scheme Procedure} / z1 z2 ...
457 @deffnx {Scheme Procedure} max x1 x2 ...
458 @deffnx {Scheme Procedure} min x1 x2 ...
459 @deffnx {Scheme Procedure} abs x
460 @deffnx {Scheme Procedure} truncate x
461 @deffnx {Scheme Procedure} floor x
462 @deffnx {Scheme Procedure} ceiling x
463 @deffnx {Scheme Procedure} round x
464 @xref{Arithmetic}, for documentation.
465 @end deffn
466
467 @rnindex div
468 @rnindex mod
469 @rnindex div-and-mod
470 @deffn {Scheme Procedure} div x y
471 @deffnx {Scheme Procedure} mod x y
472 @deffnx {Scheme Procedure} div-and-mod x y
473 These procedures accept two real numbers @var{x} and @var{y}, where the
474 divisor @var{y} must be non-zero. @code{div} returns the integer @var{q}
475 and @code{mod} returns the real number @var{r} such that
476 @math{@var{x} = @var{q}*@var{y} + @var{r}} and @math{0 <= @var{r} < abs(@var{y})}.
477 @code{div-and-mod} returns both @var{q} and @var{r}, and is more
478 efficient than computing each separately. Note that when @math{@var{y} > 0},
479 @code{div} returns @math{floor(@var{x}/@var{y})}, otherwise
480 it returns @math{ceiling(@var{x}/@var{y})}.
481
482 @lisp
483 (div 123 10) @result{} 12
484 (mod 123 10) @result{} 3
485 (div-and-mod 123 10) @result{} 12 and 3
486 (div-and-mod 123 -10) @result{} -12 and 3
487 (div-and-mod -123 10) @result{} -13 and 7
488 (div-and-mod -123 -10) @result{} 13 and 7
489 (div-and-mod -123.2 -63.5) @result{} 2.0 and 3.8
490 (div-and-mod 16/3 -10/7) @result{} -3 and 22/21
491 @end lisp
492 @end deffn
493
494 @rnindex div0
495 @rnindex mod0
496 @rnindex div0-and-mod0
497 @deffn {Scheme Procedure} div0 x y
498 @deffnx {Scheme Procedure} mod0 x y
499 @deffnx {Scheme Procedure} div0-and-mod0 x y
500 These procedures accept two real numbers @var{x} and @var{y}, where the
501 divisor @var{y} must be non-zero. @code{div0} returns the
502 integer @var{q} and @code{mod0} returns the real number
503 @var{r} such that @math{@var{x} = @var{q}*@var{y} + @var{r}} and
504 @math{-abs(@var{y}/2) <= @var{r} < abs(@var{y}/2)}. @code{div0-and-mod0}
505 returns both @var{q} and @var{r}, and is more efficient than computing
506 each separately.
507
508 Note that @code{div0} returns @math{@var{x}/@var{y}} rounded to the
509 nearest integer. When @math{@var{x}/@var{y}} lies exactly half-way
510 between two integers, the tie is broken according to the sign of
511 @var{y}. If @math{@var{y} > 0}, ties are rounded toward positive
512 infinity, otherwise they are rounded toward negative infinity.
513 This is a consequence of the requirement that
514 @math{-abs(@var{y}/2) <= @var{r} < abs(@var{y}/2)}.
515
516 @lisp
517 (div0 123 10) @result{} 12
518 (mod0 123 10) @result{} 3
519 (div0-and-mod0 123 10) @result{} 12 and 3
520 (div0-and-mod0 123 -10) @result{} -12 and 3
521 (div0-and-mod0 -123 10) @result{} -12 and -3
522 (div0-and-mod0 -123 -10) @result{} 12 and -3
523 (div0-and-mod0 -123.2 -63.5) @result{} 2.0 and 3.8
524 (div0-and-mod0 16/3 -10/7) @result{} -4 and -8/21
525 @end lisp
526 @end deffn
527
528 @deffn {Scheme Procedure} exact-integer-sqrt k
529 This procedure returns two nonnegative integer objects @code{s} and
530 @code{r} such that k = s^2 + r and k < (s + 1)^2.
531 @end deffn
532
533 @deffn {Scheme Procedure} real-valued? obj
534 @deffnx {Scheme Procedure} rational-valued? obj
535 @deffnx {Scheme Procedure} integer-valued? obj
536 These procedures return @code{#t} if and only if their arguments can,
537 respectively, be coerced to a real, rational, or integer value without a
538 loss of numerical precision.
539
540 @code{real-valued?} will return @code{#t} for complex numbers whose
541 imaginary parts are zero.
542 @end deffn
543
544 @deffn {Scheme Procedure} finite? x
545 @deffnx {Scheme Procedure} infinite? x
546 @code{infinite?} returns @code{#t} if @var{x} is an infinite value,
547 @code{#f} otherwise. @code{finite?} returns the negation of
548 @code{infinite?}.
549 @end deffn
550
551 @deffn {Scheme Syntax} assert expr
552 Raises an @code{&assertion} condition if @var{expr} evaluates to
553 @code{#f}; otherwise evaluates to the value of @var{expr}.
554 @end deffn
555
556 @deffn {Scheme Procedure} error who message irritant1 ...
557 @deffnx {Scheme Procedure} assertion-violation who message irritant1 ...
558 These procedures raise compound conditions based on their arguments:
559 If @var{who} is not @code{#f}, the condition will include a @code{&who}
560 condition whose @code{who} field is set to @var{who}; a @code{&message}
561 condition will be included with a @code{message} field equal to
562 @var{message}; an @code{&irritants} condition will be included with its
563 @code{irritants} list given by @code{irritant1 ...}.
564
565 @code{error} produces a compound condition with the simple conditions
566 described above, as well as an @code{&error} condition;
567 @code{assertion-violation} produces one that includes an
568 @code{&assertion} condition.
569 @end deffn
570
571 @deffn {Scheme Procedure} vector-map proc v
572 @deffnx {Scheme Procedure} vector-for-each proc v
573 These procedures implement the @code{map} and @code{for-each} contracts
574 over vectors.
575 @end deffn
576
577 @deffn {Scheme Procedure} vector . l
578 @deffnx {Scheme Procedure} vector? obj
579 @deffnx {Scheme Procedure} make-vector len
580 @deffnx {Scheme Procedure} make-vector len fill
581 @deffnx {Scheme Procedure} list->vector l
582 @deffnx {Scheme Procedure} vector->list v
583 @xref{Vector Creation}, for documentation.
584 @end deffn
585
586 @deffn {Scheme Procedure} vector-length vector
587 @deffnx {Scheme Procedure} vector-ref vector k
588 @deffnx {Scheme Procedure} vector-set! vector k obj
589 @deffnx {Scheme Procedure} vector-fill! v fill
590 @xref{Vector Accessors}, for documentation.
591 @end deffn
592
593 @deffn {Scheme Procedure} call-with-current-continuation proc
594 @deffnx {Scheme Procedure} call/cc proc
595 @xref{Continuations}, for documentation.
596 @end deffn
597
598 @deffn {Scheme Procedure} values arg1 ... argN
599 @deffnx {Scheme Procedure} call-with-values producer consumer
600 @xref{Multiple Values}, for documentation.
601 @end deffn
602
603 @deffn {Scheme Procedure} dynamic-wind in_guard thunk out_guard
604 @xref{Dynamic Wind}, for documentation.
605 @end deffn
606
607 @deffn {Scheme Procedure} apply proc arg1 ... argN arglst
608 @xref{Fly Evaluation}, for documentation.
609 @end deffn
610
611 @node rnrs unicode
612 @subsubsection rnrs unicode
613
614 The @code{(rnrs unicode (6))} library provides procedures for
615 manipulating Unicode characters and strings.
616
617 @deffn {Scheme Procedure} char-upcase char
618 @deffnx {Scheme Procedure} char-downcase char
619 @deffnx {Scheme Procedure} char-titlecase char
620 @deffnx {Scheme Procedure} char-foldcase char
621 These procedures translate their arguments from one Unicode character
622 set to another. @code{char-upcase}, @code{char-downcase}, and
623 @code{char-titlecase} are identical to their counterparts in the
624 Guile core library; @xref{Characters}, for documentation.
625
626 @code{char-foldcase} returns the result of applying @code{char-upcase}
627 to its argument, followed by @code{char-downcase}---except in the case
628 of the Turkic characters @code{U+0130} and @code{U+0131}, for which the
629 procedure acts as the identity function.
630 @end deffn
631
632 @deffn {Scheme Procedure} char-ci=? char1 char2 char3 ...
633 @deffnx {Scheme Procedure} char-ci<? char1 char2 char3 ...
634 @deffnx {Scheme Procedure} char-ci>? char1 char2 char3 ...
635 @deffnx {Scheme Procedure} char-ci<=? char1 char2 char3 ...
636 @deffnx {Scheme Procedure} char-ci>=? char1 char2 char3 ...
637 These procedures facilitate case-insensitive comparison of Unicode
638 characters. They are identical to the procedures provided by Guile's
639 core library. @xref{Characters}, for documentation.
640 @end deffn
641
642 @deffn {Scheme Procedure} char-alphabetic? char
643 @deffnx {Scheme Procedure} char-numeric? char
644 @deffnx {Scheme Procedure} char-whitespace? char
645 @deffnx {Scheme Procedure} char-upper-case? char
646 @deffnx {Scheme Procedure} char-lower-case? char
647 @deffnx {Scheme Procedure} char-title-case? char
648 These procedures implement various Unicode character set predicates.
649 They are identical to the procedures provided by Guile's core library.
650 @xref{Characters}, for documentation.
651 @end deffn
652
653 @deffn {Scheme Procedure} char-general-category char
654 @xref{Characters}, for documentation.
655 @end deffn
656
657 @deffn {Scheme Procedure} string-upcase string
658 @deffnx {Scheme Procedure} string-downcase string
659 @deffnx {Scheme Procedure} string-titlecase string
660 @deffnx {Scheme Procedure} string-foldcase string
661 These procedures perform Unicode case folding operations on their input.
662 @xref{Alphabetic Case Mapping}, for documentation.
663 @end deffn
664
665 @deffn {Scheme Procedure} string-ci=? string1 string2 string3 ...
666 @deffnx {Scheme Procedure} string-ci<? string1 string2 string3 ...
667 @deffnx {Scheme Procedure} string-ci>? string1 string2 string3 ...
668 @deffnx {Scheme Procedure} string-ci<=? string1 string2 string3 ...
669 @deffnx {Scheme Procedure} string-ci>=? string1 string2 string3 ...
670 These procedures perform case-insensitive comparison on their input.
671 @xref{String Comparison}, for documentation.
672 @end deffn
673
674 @deffn {Scheme Procedure} string-normalize-nfd string
675 @deffnx {Scheme Procedure} string-normalize-nfkd string
676 @deffnx {Scheme Procedure} string-normalize-nfc string
677 @deffnx {Scheme Procedure} string-normalize-nfkc string
678 These procedures perform Unicode string normalization operations on
679 their input. @xref{String Comparison}, for documentation.
680 @end deffn
681
682 @node rnrs bytevectors
683 @subsubsection rnrs bytevectors
684
685 The @code{(rnrs bytevectors (6))} library provides procedures for
686 working with blocks of binary data. This functionality is documented
687 in its own section of the manual; @xref{Bytevectors}.
688
689 @node rnrs lists
690 @subsubsection rnrs lists
691
692 The @code{(rnrs lists (6))} library provides procedures additional
693 procedures for working with lists.
694
695 @deffn {Scheme Procedure} find proc list
696 This procedure is identical to the one defined in Guile's SRFI-1
697 implementation. @xref{SRFI-1 Searching}, for documentation.
698 @end deffn
699
700 @deffn {Scheme Procedure} for-all proc list1 list2 ...
701 @deffnx {Scheme Procedure} exists proc list1 list2 ...
702
703 The @code{for-all} procedure is identical to the @code{every} procedure
704 defined by SRFI-1; the @code{exists} procedure is identical to SRFI-1's
705 @code{any}. @xref{SRFI-1 Searching}, for documentation.
706 @end deffn
707
708 @deffn {Scheme Procedure} filter proc list
709 @deffnx {Scheme Procedure} partition proc list
710 These procedures are identical to the ones provided by SRFI-1.
711 @xref{List Modification}, for a description of @code{filter};
712 @xref{SRFI-1 Filtering and Partitioning}, for @code{partition}.
713 @end deffn
714
715 @deffn {Scheme Procedure} fold-left combine nil list1 list2 ... listn
716 @deffnx {Scheme Procedure} fold-right combine nil list1 list2 ... listn
717 These procedures are identical to the @code{fold} and @code{fold-right}
718 procedures provided by SRFI-1. @xref{SRFI-1 Fold and Map}, for
719 documentation.
720 @end deffn
721
722 @deffn {Scheme Procedure} remp proc list
723 @deffnx {Scheme Procedure} remove obj list
724 @deffnx {Scheme Procedure} remv obj list
725 @deffnx {Scheme Procedure} remq obj list
726 @code{remove}, @code{remv}, and @code{remq} are identical to the
727 @code{delete}, @code{delv}, and @code{delq} procedures provided by
728 Guile's core library, (@pxref{List Modification}). @code{remp} is
729 identical to the alternate @code{remove} procedure provided by SRFI-1;
730 @xref{SRFI-1 Deleting}.
731 @end deffn
732
733 @deffn {Scheme Procedure} memp proc list
734 @deffnx {Scheme Procedure} member obj list
735 @deffnx {Scheme Procedure} memv obj list
736 @deffnx {Scheme Procedure} memq obj list
737 @code{member}, @code{memv}, and @code{memq} are identical to the
738 procedures provided by Guile's core library; @xref{List Searching},
739 for their documentation. @code{memp} uses the specified predicate
740 function @code{proc} to test elements of the list @var{list}---it
741 behaves similarly to @code{find}, except that it returns the first
742 sublist of @var{list} whose @code{car} satisfies @var{proc}.
743 @end deffn
744
745 @deffn {Scheme Procedure} assp proc alist
746 @deffnx {Scheme Procedure} assoc obj alist
747 @deffnx {Scheme Procedure} assv obj alist
748 @deffnx {Scheme Procedure} assq obj alist
749 @code{assoc}, @code{assv}, and @code{assq} are identical to the
750 procedures provided by Guile's core library;
751 @xref{Alist Key Equality}, for their documentation. @code{assp} uses
752 the specified predicate function @code{proc} to test keys in the
753 association list @var{alist}.
754 @end deffn
755
756 @deffn {Scheme Procedure} cons* obj1 ... obj
757 @deffnx {Scheme Procedure} cons* obj
758 This procedure is identical to the one exported by Guile's core
759 library. @xref{List Constructors}, for documentation.
760 @end deffn
761
762 @node rnrs sorting
763 @subsubsection rnrs sorting
764
765 The @code{(rnrs sorting (6))} library provides procedures for sorting
766 lists and vectors.
767
768 @deffn {Scheme Procedure} list-sort proc list
769 @deffnx {Scheme Procedure} vector-sort proc vector
770 These procedures return their input sorted in ascending order, without
771 modifying the original data. @var{proc} must be a procedure that takes
772 two elements from the input list or vector as arguments, and returns a
773 true value if the first is ``less'' than the second, @code{#f}
774 otherwise. @code{list-sort} returns a list; @code{vector-sort} returns
775 a vector.
776
777 Both @code{list-sort} and @code{vector-sort} are implemented in terms of
778 the @code{stable-sort} procedure from Guile's core library.
779 @xref{Sorting}, for a discussion of the behavior of that procedure.
780 @end deffn
781
782 @deffn {Scheme Procedure} vector-sort! proc vector
783 Performs a destructive, ``in-place'' sort of @var{vector}, using
784 @var{proc} as described above to determine an ascending ordering of
785 elements. @code{vector-sort!} returns an unspecified value.
786
787 This procedure is implemented in terms of the @code{sort!} procedure
788 from Guile's core library. @xref{Sorting}, for more information.
789 @end deffn
790
791 @node rnrs control
792 @subsubsection rnrs control
793
794 The @code{(rnrs control (6))} library provides syntactic forms useful
795 for constructing conditional expressions and controlling the flow of
796 execution.
797
798 @deffn {Scheme Syntax} when test expression1 expression2 ...
799 @deffnx {Scheme Syntax} unless test expression1 expression2 ...
800 The @code{when} form is evaluated by evaluating the specified @var{test}
801 expression; if the result is a true value, the @var{expression}s that
802 follow it are evaluated in order, and the value of the final
803 @var{expression} becomes the value of the entire @code{when} expression.
804
805 The @code{unless} form behaves similarly, with the exception that the
806 specified @var{expression}s are only evaluated if the value of
807 @var{test} is false.
808 @end deffn
809
810 @deffn {Scheme Syntax} do ((variable init step) ...) (test expression ...) command ...
811 This form is identical to the one provided by Guile's core library.
812 @xref{while do}, for documentation.
813 @end deffn
814
815 @deffn {Scheme Syntax} case-lambda clause ...
816 This form is identical to the one provided by Guile's core library.
817 @xref{Case-lambda}, for documentation.
818 @end deffn
819
820 @node R6RS Records
821 @subsubsection R6RS Records
822
823 The manual sections below describe Guile's implementation of R6RS
824 records, which provide support for user-defined data types. The R6RS
825 records API provides a superset of the features provided by Guile's
826 ``native'' records, as well as those of the SRFI-9 records API;
827 @xref{Records}, and @ref{SRFI-9}, for a description of those
828 interfaces.
829
830 As with SRFI-9 and Guile's native records, R6RS records are constructed
831 using a record-type descriptor that specifies attributes like the
832 record's name, its fields, and the mutability of those fields.
833
834 R6RS records extend this framework to support single inheritance via the
835 specification of a ``parent'' type for a record type at definition time.
836 Accessors and mutator procedures for the fields of a parent type may be
837 applied to records of a subtype of this parent. A record type may be
838 @dfn{sealed}, in which case it cannot be used as the parent of another
839 record type.
840
841 The inheritance mechanism for record types also informs the process of
842 initializing the fields of a record and its parents. Constructor
843 procedures that generate new instances of a record type are obtained
844 from a record constructor descriptor, which encapsulates the record-type
845 descriptor of the record to be constructed along with a @dfn{protocol}
846 procedure that defines how constructors for record subtypes delegate to
847 the constructors of their parent types.
848
849 A protocol is a procedure used by the record system at construction time
850 to bind arguments to the fields of the record being constructed. The
851 protocol procedure is passed a procedure @var{n} that accepts the
852 arguments required to construct the record's parent type; this
853 procedure, when invoked, will return a procedure @var{p} that accepts
854 the arguments required to construct a new instance of the record type
855 itself and returns a new instance of the record type.
856
857 The protocol should in turn return a procedure that uses @var{n} and
858 @var{p} to initialize the fields of the record type and its parent
859 type(s). This procedure will be the constructor returned by
860
861 As a trivial example, consider the hypothetical record type
862 @code{pixel}, which encapsulates an x-y location on a screen, and
863 @code{voxel}, which has @code{pixel} as its parent type and stores an
864 additional coordinate. The following protocol produces a constructor
865 procedure that accepts all three coordinates, uses the first two to
866 initialize the fields of @code{pixel}, and binds the third to the single
867 field of @code{voxel}.
868
869 @lisp
870 (lambda (n)
871 (lambda (x y z)
872 (let ((p (n x y)))
873 (p z))))
874 @end lisp
875
876 It may be helpful to think of protocols as ``constructor factories''
877 that produce chains of delegating constructors glued together by the
878 helper procedure @var{n}.
879
880 An R6RS record type may be declared to be @dfn{nongenerative} via the
881 use of a unique generated or user-supplied symbol---or
882 @dfn{uid}---such that subsequent record type declarations with the same
883 uid and attributes will return the previously-declared record-type
884 descriptor.
885
886 R6RS record types may also be declared to be @dfn{opaque}, in which case
887 the various predicates and introspection procedures defined in
888 @code{(rnrs records introspection)} will behave as if records of this
889 type are not records at all.
890
891 Note that while the R6RS records API shares much of its namespace with
892 both the SRFI-9 and native Guile records APIs, it is not currently
893 compatible with either.
894
895 @node rnrs records syntactic
896 @subsubsection rnrs records syntactic
897
898 The @code{(rnrs records syntactic (6))} library exports the syntactic
899 API for working with R6RS records.
900
901 @deffn {Scheme Syntax} define-record-type name-spec record-clause*
902 Defines a new record type, introducing bindings for a record-type
903 descriptor, a record constructor descriptor, a constructor procedure,
904 a record predicate, and accessor and mutator procedures for the new
905 record type's fields.
906
907 @var{name-spec} must either be an identifier or must take the form
908 @code{(record-name constructor-name predicate-name)}, where
909 @var{record-name}, @var{constructor-name}, and @var{predicate-name} are
910 all identifiers and specify the names to which, respectively, the
911 record-type descriptor, constructor, and predicate procedures will be
912 bound. If @var{name-spec} is only an identifier, it specifies the name
913 to which the generated record-type descriptor will be bound.
914
915 Each @var{record-clause} must be one of the following:
916
917 @itemize @bullet
918 @item
919 @code{(fields field-spec*)}, where each @var{field-spec} specifies a
920 field of the new record type and takes one of the following forms:
921 @itemize @bullet
922 @item
923 @code{(immutable field-name accessor-name)}, which specifies an
924 immutable field with the name @var{field-name} and binds an accessor
925 procedure for it to the name given by @var{accessor-name}
926 @item
927 @code{(mutable field-name accessor-name mutator-name)}, which specifies
928 a mutable field with the name @var{field-name} and binds accessor and
929 mutator procedures to @var{accessor-name} and @var{mutator-name},
930 respectively
931 @item
932 @code{(immutable field-name)}, which specifies an immutable field with
933 the name @var{field-name}; an accessor procedure for it will be created
934 and named by appending record name and @var{field-name} with a hyphen
935 separator
936 @item
937 @code{(mutable field-name}), which specifies a mutable field with the
938 name @var{field-name}; an accessor procedure for it will be created and
939 named as described above; a mutator procedure will also be created and
940 named by appending @code{-set!} to the accessor name
941 @item
942 @code{field-name}, which specifies an immutable field with the name
943 @var{field-name}; an access procedure for it will be created and named
944 as described above
945 @end itemize
946 @item
947 @code{(parent parent-name)}, where @var{parent-name} is a symbol giving
948 the name of the record type to be used as the parent of the new record
949 type
950 @item
951 @code{(protocol expression)}, where @var{expression} evaluates to a
952 protocol procedure which behaves as described above, and is used to
953 create a record constructor descriptor for the new record type
954 @item
955 @code{(sealed sealed?)}, where @var{sealed?} is a boolean value that
956 specifies whether or not the new record type is sealed
957 @item
958 @code{(opaque opaque?)}, where @var{opaque?} is a boolean value that
959 specifies whether or not the new record type is opaque
960 @item
961 @code{(nongenerative [uid])}, which specifies that the record type is
962 nongenerative via the optional uid @var{uid}. If @var{uid} is not
963 specified, a unique uid will be generated at expansion time
964 @item
965 @code{(parent-rtd parent-rtd parent-cd)}, a more explicit form of the
966 @code{parent} form above; @var{parent-rtd} and @var{parent-cd} should
967 evaluate to a record-type descriptor and a record constructor
968 descriptor, respectively
969 @end itemize
970 @end deffn
971
972 @deffn {Scheme Syntax} record-type-descriptor record-name
973 Evaluates to the record-type descriptor associated with the type
974 specified by @var{record-name}.
975 @end deffn
976
977 @deffn {Scheme Syntax} record-constructor-descriptor record-name
978 Evaluates to the record-constructor descriptor associated with the type
979 specified by @var{record-name}.
980 @end deffn
981
982 @node rnrs records procedural
983 @subsubsection rnrs records procedural
984
985 The @code{(rnrs records procedural (6))} library exports the procedural
986 API for working with R6RS records.
987
988 @deffn {Scheme Procedure} make-record-type-descriptor name parent uid sealed? opaque? fields
989 Returns a new record-type descriptor with the specified characteristics:
990 @var{name} must be a symbol giving the name of the new record type;
991 @var{parent} must be either @code{#f} or a non-sealed record-type
992 descriptor for the returned record type to extend; @var{uid} must be
993 either @code{#f}, indicating that the record type is generative, or
994 a symbol giving the type's nongenerative uid; @var{sealed?} and
995 @var{opaque?} must be boolean values that specify the sealedness and
996 opaqueness of the record type; @var{fields} must be a vector of zero or
997 more field specifiers of the form @code{(mutable name)} or
998 @code{(immutable name)}, where name is a symbol giving a name for the
999 field.
1000
1001 If @var{uid} is not @code{#f}, it must be a symbol
1002 @end deffn
1003
1004 @deffn {Scheme Procedure} record-type-descriptor? obj
1005 Returns @code{#t} if @var{obj} is a record-type descriptor, @code{#f}
1006 otherwise.
1007 @end deffn
1008
1009 @deffn {Scheme Procedure} make-record-constructor-descriptor rtd parent-constructor-descriptor protocol
1010 Returns a new record constructor descriptor that can be used to produce
1011 constructors for the record type specified by the record-type descriptor
1012 @var{rtd} and whose delegation and binding behavior are specified by the
1013 protocol procedure @var{protocol}.
1014
1015 @var{parent-constructor-descriptor} specifies a record constructor
1016 descriptor for the parent type of @var{rtd}, if one exists. If
1017 @var{rtd} represents a base type, then
1018 @var{parent-constructor-descriptor} must be @code{#f}. If @var{rtd}
1019 is an extension of another type, @var{parent-constructor-descriptor} may
1020 still be @code{#f}, but protocol must also be @code{#f} in this case.
1021 @end deffn
1022
1023 @deffn {Scheme Procedure} record-constructor rcd
1024 Returns a record constructor procedure by invoking the protocol
1025 defined by the record-constructor descriptor @var{rcd}.
1026 @end deffn
1027
1028 @deffn {Scheme Procedure} record-predicate rtd
1029 Returns the record predicate procedure for the record-type descriptor
1030 @var{rtd}.
1031 @end deffn
1032
1033 @deffn {Scheme Procedure} record-accessor rtd k
1034 Returns the record field accessor procedure for the @var{k}th field of
1035 the record-type descriptor @var{rtd}.
1036 @end deffn
1037
1038 @deffn {Scheme Procedure} record-mutator rtd k
1039 Returns the record field mutator procedure for the @var{k}th field of
1040 the record-type descriptor @var{rtd}. An @code{&assertion} condition
1041 will be raised if this field is not mutable.
1042 @end deffn
1043
1044 @node rnrs records inspection
1045 @subsubsection rnrs records inspection
1046
1047 The @code{(rnrs records inspection (6))} library provides procedures
1048 useful for accessing metadata about R6RS records.
1049
1050 @deffn {Scheme Procedure} record? obj
1051 Return @code{#t} if the specified object is a non-opaque R6RS record,
1052 @code{#f} otherwise.
1053 @end deffn
1054
1055 @deffn {Scheme Procedure} record-rtd record
1056 Returns the record-type descriptor for @var{record}. An
1057 @code{&assertion} is raised if @var{record} is opaque.
1058 @end deffn
1059
1060 @deffn {Scheme Procedure} record-type-name rtd
1061 Returns the name of the record-type descriptor @var{rtd}.
1062 @end deffn
1063
1064 @deffn {Scheme Procedure} record-type-parent rtd
1065 Returns the parent of the record-type descriptor @var{rtd}, or @code{#f}
1066 if it has none.
1067 @end deffn
1068
1069 @deffn {Scheme Procedure} record-type-uid rtd
1070 Returns the uid of the record-type descriptor @var{rtd}, or @code{#f} if
1071 it has none.
1072 @end deffn
1073
1074 @deffn {Scheme Procedure} record-type-generative? rtd
1075 Returns @code{#t} if the record-type descriptor @var{rtd} is generative,
1076 @code{#f} otherwise.
1077 @end deffn
1078
1079 @deffn {Scheme Procedure} record-type-sealed? rtd
1080 Returns @code{#t} if the record-type descriptor @var{rtd} is sealed,
1081 @code{#f} otherwise.
1082 @end deffn
1083
1084 @deffn {Scheme Procedure} record-type-opaque? rtd
1085 Returns @code{#t} if the record-type descriptor @var{rtd} is opaque,
1086 @code{#f} otherwise.
1087 @end deffn
1088
1089 @deffn {Scheme Procedure} record-type-field-names rtd
1090 Returns a vector of symbols giving the names of the fields defined by
1091 the record-type descriptor @var{rtd} (and not any of its sub- or
1092 supertypes).
1093 @end deffn
1094
1095 @deffn {Scheme Procedure} record-field-mutable? rtd k
1096 Returns @code{#t} if the field at index @var{k} of the record-type
1097 descriptor @var{rtd} (and not any of its sub- or supertypes) is mutable.
1098 @end deffn
1099
1100 @node rnrs exceptions
1101 @subsubsection rnrs exceptions
1102
1103 The @code{(rnrs exceptions (6))} library provides functionality related
1104 to signaling and handling exceptional situations. This functionality is
1105 similar to the exception handling systems provided by Guile's core
1106 library @xref{Exceptions}, and by the SRFI-18 and SRFI-34
1107 modules---@xref{SRFI-18 Exceptions}, and @ref{SRFI-34},
1108 respectively---but there are some key differences in concepts and
1109 behavior.
1110
1111 A raised exception may be @dfn{continuable} or @dfn{non-continuable}.
1112 When an exception is raised non-continuably, another exception, with the
1113 condition type @code{&non-continuable}, will be raised when the
1114 exception handler returns locally. Raising an exception continuably
1115 captures the current continuation and invokes it after a local return
1116 from the exception handler.
1117
1118 Like SRFI-18 and SRFI-34, R6RS exceptions are implemented on top of
1119 Guile's native @code{throw} and @code{catch} forms, and use custom
1120 ``throw keys'' to identify their exception types. As a consequence,
1121 Guile's @code{catch} form can handle exceptions thrown by these APIs,
1122 but the reverse is not true: Handlers registered by the
1123 @code{with-exception-handler} procedure described below will only be
1124 called on exceptions thrown by the corresponding @code{raise} procedure.
1125
1126 @deffn {Scheme Procedure} with-exception-handler handler thunk
1127 Installs @var{handler}, which must be a procedure taking one argument,
1128 as the current exception handler during the invokation of @var{thunk}, a
1129 procedure taking zero arguments. The handler in place at the time
1130 @code{with-exception-handler} is called is made current again once
1131 either @var{thunk} returns or @var{handler} is invoked after an
1132 exception is thrown from within @var{thunk}.
1133
1134 This procedure is similar to the @code{with-throw-handler} procedure
1135 provided by Guile's code library; (@pxref{Throw Handlers}).
1136 @end deffn
1137
1138 @deffn {Scheme Syntax} guard (variable clause1 clause2 ...) body
1139 Evaluates the expression given by @var{body}, first creating an ad hoc
1140 exception handler that binds a raised exception to @var{variable} and
1141 then evaluates the specified @var{clause}s as if they were part of a
1142 @code{cond} expression, with the value of the first matching clause
1143 becoming the value of the @code{guard} expression
1144 (@pxref{if cond case}). If none of the clause's test expressions
1145 evaluates to @code{#t}, the exception is re-raised, with the exception
1146 handler that was current before the evaluation of the @code{guard} form.
1147
1148 For example, the expression
1149
1150 @lisp
1151 (guard (ex ((eq? ex 'foo) 'bar) ((eq? ex 'bar) 'baz))
1152 (raise 'bar))
1153 @end lisp
1154
1155 evaluates to @code{baz}.
1156 @end deffn
1157
1158 @deffn {Scheme Procedure} raise obj
1159 Raises a non-continuable exception by invoking the currently-installed
1160 exception handler on @var{obj}. If the handler returns, a
1161 @code{&non-continuable} exception will be raised in the dynamic context
1162 in which the handler was installed.
1163 @end deffn
1164
1165 @deffn {Scheme Procedure} raise-continuable obj
1166 Raises a continuable exception by invoking currently-installed exception
1167 handler on @var{obj}.
1168 @end deffn
1169
1170 @node rnrs conditions
1171 @subsubsection rnrs conditions
1172
1173 The @code{(rnrs condition (6))} library provides forms and procedures
1174 for constructing new condition types, as well as a library of
1175 pre-defined condition types that represent a variety of common
1176 exceptional situations. Conditions are records of a subtype of the
1177 @code{&condition} record type, which is neither sealed nor opaque.
1178 @xref{R6RS Records}.
1179
1180 Conditions may be manipulated singly, as @dfn{simple conditions}, or
1181 when composed with other conditions to form @dfn{compound conditions}.
1182 Compound conditions do not ``nest''---constructing a new compound
1183 condition out of existing compound conditions will ``flatten'' them
1184 into their component simple conditions. For example, making a new
1185 condition out of a @code{&message} condition and a compound condition
1186 that contains an @code{&assertion} condition and another @code{&message}
1187 condition will produce a compound condition that contains two
1188 @code{&message} conditions and one @code{&assertion} condition.
1189
1190 The record type predicates and field accessors described below can
1191 operate on either simple or compound conditions. In the latter case,
1192 the predicate returns @code{#t} if the compound condition contains a
1193 component simple condition of the appropriate type; the field accessors
1194 return the requisite fields from the first component simple condition
1195 found to be of the appropriate type.
1196
1197 This library is quite similar to the SRFI-35 conditions module
1198 (@pxref{SRFI-35}). Among other minor differences, the
1199 @code{(rnrs conditions)} library features slightly different semantics
1200 around condition field accessors, and comes with a larger number of
1201 pre-defined condition types. The two APIs are not currently compatible,
1202 however; the @code{condition?} predicate from one API will return
1203 @code{#f} when applied to a condition object created in the other.
1204
1205 @deffn {Condition Type} &condition
1206 @deffnx {Scheme Procedure} condition? obj
1207 The base record type for conditions.
1208 @end deffn
1209
1210 @deffn {Scheme Procedure} condition condition1 ...
1211 @deffnx {Scheme Procedure} simple-conditions condition
1212 The @code{condition} procedure creates a new compound condition out of
1213 its condition arguments, flattening any specified compound conditions
1214 into their component simple conditions as described above.
1215
1216 @code{simple-conditions} returns a list of the component simple
1217 conditions of the compound condition @code{condition}, in the order in
1218 which they were specified at construction time.
1219 @end deffn
1220
1221 @deffn {Scheme Procedure} condition-predicate rtd
1222 @deffnx {Scheme Procedure} condition-accessor rtd proc
1223 These procedures return condition predicate and accessor procedures for
1224 the specified condition record type @var{rtd}.
1225 @end deffn
1226
1227 @deffn {Scheme Syntax} define-condition-type condition-type supertype constructor predicate field-spec ...
1228 Evaluates to a new record type definition for a condition type with the
1229 name @var{condition-type} that has the condition type @var{supertype} as
1230 its parent. A default constructor, which binds its arguments to the
1231 fields of this type and its parent types, will be bound to the
1232 identifier @var{constructor}; a condition predicate will be bound to
1233 @var{predicate}. The fields of the new type, which are immutable, are
1234 specified by the @var{field-spec}s, each of which must be of the form:
1235 @lisp
1236 (field accessor)
1237 @end lisp
1238 where @var{field} gives the name of the field and @var{accessor} gives
1239 the name for a binding to an accessor procedure created for this field.
1240 @end deffn
1241
1242 @deffn {Condition Type} &message
1243 @deffnx {Scheme Procedure} make-message-condition message
1244 @deffnx {Scheme Procedure} message-condition? obj
1245 @deffnx {Scheme Procedure} condition-message condition
1246 A type that includes a message describing the condition that occurred.
1247 @end deffn
1248
1249 @deffn {Condition Type} &warning
1250 @deffnx {Scheme Procedure} make-warning
1251 @deffnx {Scheme Procedure} warning? obj
1252 A base type for representing non-fatal conditions during execution.
1253 @end deffn
1254
1255 @deffn {Condition Type} &serious
1256 @deffnx {Scheme Procedure} make-serious-condition
1257 @deffnx {Scheme Procedure} serious-condition? obj
1258 A base type for conditions representing errors serious enough that
1259 cannot be ignored.
1260 @end deffn
1261
1262 @deffn {Condition Type} &error
1263 @deffnx {Scheme Procedure} make-error
1264 @deffnx {Scheme Procedure} error? obj
1265 A base type for conditions representing errors.
1266 @end deffn
1267
1268 @deffn {Condition Type} &violation
1269 @deffnx {Scheme Procedure} make-violation
1270 @deffnx {Scheme Procedure} violation?
1271 A subtype of @code{&serious} that can be used to represent violations
1272 of a language or library standard.
1273 @end deffn
1274
1275 @deffn {Condition Type} &assertion
1276 @deffnx {Scheme Procedure} make-assertion-violation
1277 @deffnx {Scheme Procedure} assertion-violation? obj
1278 A subtype of @code{&violation} that indicates an invalid call to a
1279 procedure.
1280 @end deffn
1281
1282 @deffn {Condition Type} &irritants
1283 @deffnx {Scheme Procedure} make-irritants-condition irritants
1284 @deffnx {Scheme Procedure} irritants-condition? obj
1285 @deffnx {Scheme Procedure} condition-irritants condition
1286 A base type used for storing information about the causes of another
1287 condition in a compound condition.
1288 @end deffn
1289
1290 @deffn {Condition Type} &who
1291 @deffnx {Scheme Procedure} make-who-condition who
1292 @deffnx {Scheme Procedure} who-condition? obj
1293 @deffnx {Scheme Procedure} condiction-who condition
1294 A base type used for storing the identity, a string or symbol, of the
1295 entity responsible for another condition in a compound condition.
1296 @end deffn
1297
1298 @deffn {Condition Type} &non-continuable
1299 @deffnx {Scheme Procedure} make-non-continuable-violation
1300 @deffnx {Scheme Procedure} non-continuable-violation? obj
1301 A subtype of @code{&violation} used to indicate that an exception
1302 handler invoked by @code{raise} has returned locally.
1303 @end deffn
1304
1305 @deffn {Condition Type} &implementation-restriction
1306 @deffnx {Scheme Procedure} make-implementation-restriction-violation
1307 @deffnx {Scheme Procedure} implementation-restriction-violation? obj
1308 A subtype of @code{&violation} used to indicate a violation of an
1309 implementation restriction.
1310 @end deffn
1311
1312 @deffn {Condition Type} &lexical
1313 @deffnx {Scheme Procedure} make-lexical-violation
1314 @deffnx {Scheme Procedure} lexical-violation? obj
1315 A subtype of @code{&violation} used to indicate a syntax violation at
1316 the level of the datum syntax.
1317 @end deffn
1318
1319 @deffn {Condition Type} &syntax
1320 @deffnx {Scheme Procedure} make-syntax-violation form subform
1321 @deffnx {Scheme Procedure} syntax-violation? obj
1322 @deffnx {Scheme Procedure} syntax-violation-form condition
1323 @deffnx {Scheme Procedure} syntax-violation-subform condition
1324 A subtype of @code{&violation} that indicates a syntax violation. The
1325 @var{form} and @var{subform} fields, which must be datum values,
1326 indicate the syntactic form responsible for the condition.
1327 @end deffn
1328
1329 @deffn {Condition Type} &undefined
1330 @deffnx {Scheme Procedure} make-undefined-violation
1331 @deffnx {Scheme Procedure} undefined-violation? obj
1332 A subtype of @code{&violation} that indicates a reference to an unbound
1333 identifier.
1334 @end deffn
1335
1336 @node I/O Conditions
1337 @subsubsection I/O Conditions
1338
1339 These condition types are exported by both the
1340 @code{(rnrs io ports (6))} and @code{(rnrs io simple (6))} libraries.
1341
1342 @deffn {Condition Type} &i/o
1343 @deffnx {Scheme Procedure} make-i/o-error
1344 @deffnx {Scheme Procedure} i/o-error? obj
1345 A condition supertype for more specific I/O errors.
1346 @end deffn
1347
1348 @deffn {Condition Type} &i/o-read
1349 @deffnx {Scheme Procedure} make-i/o-read-error
1350 @deffnx {Scheme Procedure} i/o-read-error? obj
1351 A subtype of @code{&i/o}; represents read-related I/O errors.
1352 @end deffn
1353
1354 @deffn {Condition Type} &i/o-write
1355 @deffnx {Scheme Procedure} make-i/o-write-error
1356 @deffnx {Scheme Procedure} i/o-write-error? obj
1357 A subtype of @code{&i/o}; represents write-related I/O errors.
1358 @end deffn
1359
1360 @deffn {Condition Type} &i/o-invalid-position
1361 @deffnx {Scheme Procedure} make-i/o-invalid-position-error position
1362 @deffnx {Scheme Procedure} i/o-invalid-position-error? obj
1363 @deffnx {Scheme Procedure} i/o-error-position condition
1364 A subtype of @code{&i/o}; represents an error related to an attempt to
1365 set the file position to an invalid position.
1366 @end deffn
1367
1368 @deffn {Condition Type} &i/o-filename
1369 @deffnx {Scheme Procedure} make-io-filename-error filename
1370 @deffnx {Scheme Procedure} i/o-filename-error? obj
1371 @deffnx {Scheme Procedure} i/o-error-filename condition
1372 A subtype of @code{&i/o}; represents an error related to an operation on
1373 a named file.
1374 @end deffn
1375
1376 @deffn {Condition Type} &i/o-file-protection
1377 @deffnx {Scheme Procedure} make-i/o-file-protection-error filename
1378 @deffnx {Scheme Procedure} i/o-file-protection-error? obj
1379 A subtype of @code{&i/o-filename}; represents an error resulting from an
1380 attempt to access a named file for which the caller had insufficient
1381 permissions.
1382 @end deffn
1383
1384 @deffn {Condition Type} &i/o-file-is-read-only
1385 @deffnx {Scheme Procedure} make-i/o-file-is-read-only-error filename
1386 @deffnx {Scheme Procedure} i/o-file-is-read-only-error? obj
1387 A subtype of @code{&i/o-file-protection}; represents an error related to
1388 an attempt to write to a read-only file.
1389 @end deffn
1390
1391 @deffn {Condition Type} &i/o-file-already-exists
1392 @deffnx {Scheme Procedure} make-i/o-file-already-exists-error filename
1393 @deffnx {Scheme Procedure} i/o-file-already-exists-error? obj
1394 A subtype of @code{&i/o-filename}; represents an error related to an
1395 operation on an existing file that was assumed not to exist.
1396 @end deffn
1397
1398 @deffn {Condition Type} &i/o-file-does-not-exist
1399 @deffnx {Scheme Procedure} make-i/o-file-does-not-exist-error
1400 @deffnx {Scheme Procedure} i/o-file-does-not-exist-error? obj
1401 A subtype of @code{&i/o-filename}; represents an error related to an
1402 operation on a non-existent file that was assumed to exist.
1403 @end deffn
1404
1405 @deffn {Condition Type} &i/o-port
1406 @deffnx {Scheme Procedure} make-i/o-port-error port
1407 @deffnx {Scheme Procedure} i/o-port-error? obj
1408 @deffnx {Scheme Procedure} i/o-error-port condition
1409 A subtype of @code{&i/o}; represents an error related to an operation on
1410 the port @var{port}.
1411 @end deffn
1412
1413 @node rnrs io ports
1414 @subsubsection rnrs io ports
1415
1416 The @code{(rnrs io ports (6))} library provides various procedures and
1417 syntactic forms for use in writing to and reading from ports. This
1418 functionality is documented in its own section of the manual;
1419 (@pxref{R6RS I/O Ports}).
1420
1421 @node rnrs io simple
1422 @subsubsection rnrs io simple
1423
1424 The @code{(rnrs io simple (6))} library provides convenience functions
1425 for performing textual I/O on ports. This library also exports all of
1426 the condition types and associated procedures described in
1427 (@pxref{I/O Conditions}).
1428
1429 @deffn {Scheme Procedure} eof-object
1430 @deffnx {Scheme Procedure} eof-object? obj
1431 These procedures are identical to the ones provided by the
1432 @code{(rnrs io ports (6))} library. @xref{R6RS I/O Ports}, for
1433 documentation.
1434 @end deffn
1435
1436 @deffn {Scheme Procedure} input-port? obj
1437 @deffnx {Scheme Procedure} output-port? obj
1438 These procedures are identical to the ones provided by Guile's core
1439 library. @xref{Ports}, for documentation.
1440 @end deffn
1441
1442 @deffn {Scheme Procedure} call-with-input-file filename proc
1443 @deffnx {Scheme Procedure} call-with-output-file filename proc
1444 @deffnx {Scheme Procedure} open-input-file filename
1445 @deffnx {Scheme Procedure} open-output-file filename
1446 @deffnx {Scheme Procedure} with-input-from-file filename thunk
1447 @deffnx {Scheme Procedure} with-output-to-file filename thunk
1448 These procedures are identical to the ones provided by Guile's core
1449 library. @xref{File Ports}, for documentation.
1450 @end deffn
1451
1452 @deffn {Scheme Procedure} close-input-port input-port
1453 @deffnx {Scheme Procedure} close-output-port output-port
1454 These procedures are identical to the ones provided by Guile's core
1455 library. @xref{Closing}, for documentation.
1456 @end deffn
1457
1458 @deffn {Scheme Procedure} peek-char
1459 @deffnx {Scheme Procedure} peek-char textual-input-port
1460 @deffnx {Scheme Procedure} read-char
1461 @deffnx {Scheme Procedure} read-char textual-input-port
1462 These procedures are identical to the ones provided by Guile's core
1463 library. @xref{Reading}, for documentation.
1464 @end deffn
1465
1466 @deffn {Scheme Procedure} read
1467 @deffnx {Scheme Procedure} read textual-input-port
1468 This procedure is identical to the one provided by Guile's core library.
1469 @xref{Scheme Read}, for documentation.
1470 @end deffn
1471
1472 @deffn {Scheme Procedure} display obj
1473 @deffnx {Scheme Procedure} display obj textual-output-port
1474 @deffnx {Scheme Procedure} newline
1475 @deffnx {Scheme Procedure} newline textual-output-port
1476 @deffnx {Scheme Procedure} write obj
1477 @deffnx {Scheme Procedure} write obj textual-output-port
1478 @deffnx {Scheme Procedure} write-char char
1479 @deffnx {Scheme Procedure} write-char char textual-output-port
1480 These procedures are identical to the ones provided by Guile's core
1481 library. @xref{Writing}, for documentation.
1482 @end deffn
1483
1484 @node rnrs files
1485 @subsubsection rnrs files
1486
1487 The @code{(rnrs files (6))} library provides the @code{file-exists?} and
1488 @code{delete-file} procedures, which test for the existence of a file
1489 and allow the deletion of files from the file system, respectively.
1490
1491 These procedures are identical to the ones provided by Guile's core
1492 library. @xref{File System}, for documentation.
1493
1494 @node rnrs programs
1495 @subsubsection rnrs programs
1496
1497 The @code{(rnrs programs (6))} library provides procedures for
1498 process management and introspection.
1499
1500 @deffn {Scheme Procedure} command-line
1501 This procedure is identical to the one provided by Guile's core library.
1502 @xref{Runtime Environment}, for documentation.
1503 @end deffn
1504
1505 @deffn {Scheme Procedure} exit
1506 @deffnx {Scheme Procedure} exit obj
1507 This procedure is identical to the one provided by Guile's core library.
1508 @end deffn
1509
1510 @node rnrs arithmetic fixnums
1511 @subsubsection rnrs arithmetic fixnums
1512
1513 The @code{(rnrs arithmetic fixnums (6))} library provides procedures for
1514 performing arithmetic operations on an implementation-dependent range of
1515 exact integer values, which R6RS refers to as @dfn{fixnums}. In Guile,
1516 the size of a fixnum is determined by the size of the @code{SCM} type; a
1517 single SCM struct is guaranteed to be able to hold an entire fixnum,
1518 making fixnum computations particularly
1519 efficient---(@pxref{The SCM Type}). On 32-bit systems, the most
1520 negative and most positive fixnum values are, respectively, -536870912
1521 and 536870911.
1522
1523 Unless otherwise specified, all of the procedures below take fixnums as
1524 arguments, and will raise an @code{&assertion} condition if passed a
1525 non-fixnum argument or an @code{&implementation-restriction} condition
1526 if their result is not itself a fixnum.
1527
1528 @deffn {Scheme Procedure} fixnum? obj
1529 Returns @code{#t} if @var{obj} is a fixnum, @code{#f} otherwise.
1530 @end deffn
1531
1532 @deffn {Scheme Procedure} fixnum-width
1533 @deffnx {Scheme Procedure} least-fixnum
1534 @deffnx {Scheme Procedure} greatest-fixnum
1535 These procedures return, respectively, the maximum number of bits
1536 necessary to represent a fixnum value in Guile, the minimum fixnum
1537 value, and the maximum fixnum value.
1538 @end deffn
1539
1540 @deffn {Scheme Procedure} fx=? fx1 fx2 fx3 ...
1541 @deffnx {Scheme Procedure} fx>? fx1 fx2 fx3 ...
1542 @deffnx {Scheme Procedure} fx<? fx1 fx2 fx3 ...
1543 @deffnx {Scheme Procedure} fx>=? fx1 fx2 fx3 ...
1544 @deffnx {Scheme Procedure} fx<=? fx1 fx2 fx3 ...
1545 These procedures return @code{#t} if their fixnum arguments are
1546 (respectively): equal, monotonically increasing, monotonically
1547 decreasing, monotonically nondecreasing, or monotonically nonincrasing;
1548 @code{#f} otherwise.
1549 @end deffn
1550
1551 @deffn {Scheme Procedure} fxzero? fx
1552 @deffnx {Scheme Procedure} fxpositive? fx
1553 @deffnx {Scheme Procedure} fxnegative? fx
1554 @deffnx {Scheme Procedure} fxodd? fx
1555 @deffnx {Scheme Procedure} fxeven? fx
1556 These numerical predicates return @code{#t} if @var{fx} is,
1557 respectively, zero, greater than zero, less than zero, odd, or even;
1558 @code{#f} otherwise.
1559 @end deffn
1560
1561 @deffn {Scheme Procedure} fxmax fx1 fx2 ...
1562 @deffnx {Scheme Procedure} fxmin fx1 fx2 ...
1563 These procedures return the maximum or minimum of their arguments.
1564 @end deffn
1565
1566 @deffn {Scheme Procedure} fx+ fx1 fx2
1567 @deffnx {Scheme Procedure} fx* fx1 fx2
1568 These procedures return the sum or product of their arguments.
1569 @end deffn
1570
1571 @deffn {Scheme Procedure} fx- fx1 fx2
1572 @deffnx {Scheme Procedure} fx- fx
1573 Returns the difference of @var{fx1} and @var{fx2}, or the negation of
1574 @var{fx}, if called with a single argument.
1575
1576 An @code{&assertion} condition is raised if the result is not itself a
1577 fixnum.
1578 @end deffn
1579
1580 @deffn {Scheme Procedure} fxdiv-and-mod fx1 fx2
1581 @deffnx {Scheme Procedure} fxdiv fx1 fx2
1582 @deffnx {Scheme Procedure} fxmod fx1 fx2
1583 @deffnx {Scheme Procedure} fxdiv0-and-mod0 fx1 fx2
1584 @deffnx {Scheme Procedure} fxdiv0 fx1 fx2
1585 @deffnx {Scheme Procedure} fxmod0 fx1 fx2
1586 These procedures implement number-theoretic division on fixnums;
1587 @xref{(rnrs base)}, for a description of their semantics.
1588 @end deffn
1589
1590 @deffn {Scheme Procedure} fx+/carry fx1 fx2 fx3
1591 Returns the two fixnum results of the following computation:
1592 @lisp
1593 (let* ((s (+ fx1 fx2 fx3))
1594 (s0 (mod0 s (expt 2 (fixnum-width))))
1595 (s1 (div0 s (expt 2 (fixnum-width)))))
1596 (values s0 s1))
1597 @end lisp
1598 @end deffn
1599
1600 @deffn {Scheme Procedure} fx-/carry fx1 fx2 fx3
1601 Returns the two fixnum results of the following computation:
1602 @lisp
1603 (let* ((d (- fx1 fx2 fx3))
1604 (d0 (mod0 d (expt 2 (fixnum-width))))
1605 (d1 (div0 d (expt 2 (fixnum-width)))))
1606 (values d0 d1))
1607 @end lisp
1608 @end deffn
1609
1610 @deffn {Scheme Procedure} fx*/carry fx1 fx2 fx3
1611 @lisp
1612 Returns the two fixnum results of the following computation:
1613 (let* ((s (+ (* fx1 fx2) fx3))
1614 (s0 (mod0 s (expt 2 (fixnum-width))))
1615 (s1 (div0 s (expt 2 (fixnum-width)))))
1616 (values s0 s1))
1617 @end lisp
1618 @end deffn
1619
1620 @deffn {Scheme Procedure} fxnot fx
1621 @deffnx {Scheme Procedure} fxand fx1 ...
1622 @deffnx {Scheme Procedure} fxior fx1 ...
1623 @deffnx {Scheme Procedure} fxxor fx1 ...
1624 These procedures are identical to the @code{lognot}, @code{logand},
1625 @code{logior}, and @code{logxor} procedures provided by Guile's core
1626 library. @xref{Bitwise Operations}, for documentation.
1627 @end deffn
1628
1629 @deffn {Scheme Procedure} fxif fx1 fx2 fx3
1630 Returns the bitwise ``if'' of its fixnum arguments. The bit at position
1631 @code{i} in the return value will be the @code{i}th bit from @var{fx2}
1632 if the @code{i}th bit of @var{fx1} is 1, the @code{i}th bit from
1633 @var{fx3}.
1634 @end deffn
1635
1636 @deffn {Scheme Procedure} fxbit-count fx
1637 Returns the number of 1 bits in the two's complement representation of
1638 @var{fx}.
1639 @end deffn
1640
1641 @deffn {Scheme Procedure} fxlength fx
1642 Returns the number of bits necessary to represent @var{fx}.
1643 @end deffn
1644
1645 @deffn {Scheme Procedure} fxfirst-bit-set fx
1646 Returns the index of the least significant 1 bit in the two's complement
1647 representation of @var{fx}.
1648 @end deffn
1649
1650 @deffn {Scheme Procedure} fxbit-set? fx1 fx2
1651 Returns @code{#t} if the @var{fx2}th bit in the two's complement
1652 representation of @var{fx1} is 1, @code{#f} otherwise.
1653 @end deffn
1654
1655 @deffn {Scheme Procedure} fxcopy-bit fx1 fx2 fx3
1656 Returns the result of setting the @var{fx2}th bit of @var{fx1} to the
1657 @var{fx2}th bit of @var{fx3}.
1658 @end deffn
1659
1660 @deffn {Scheme Procedure} fxbit-field fx1 fx2 fx3
1661 Returns the integer representation of the contiguous sequence of bits in
1662 @var{fx1} that starts at position @var{fx2} (inclusive) and ends at
1663 position @var{fx3} (exclusive).
1664 @end deffn
1665
1666 @deffn {Scheme Procedure} fxcopy-bit-field fx1 fx2 fx3 fx4
1667 Returns the result of replacing the bit field in @var{fx1} with start
1668 and end positions @var{fx2} and @var{fx3} with the corresponding bit
1669 field from @var{fx4}.
1670 @end deffn
1671
1672 @deffn {Scheme Procedure} fxarithmetic-shift fx1 fx2
1673 @deffnx {Scheme Procedure} fxarithmetic-shift-left fx1 fx2
1674 @deffnx {Scheme Procedure} fxarithmetic-shift-right fx1 fx2
1675 Returns the result of shifting the bits of @var{fx1} right or left by
1676 the @var{fx2} positions. @code{fxarithmetic-shift} is identical
1677 to @code{fxarithmetic-shift-left}.
1678 @end deffn
1679
1680 @deffn {Scheme Procedure} fxrotate-bit-field fx1 fx2 fx3 fx4
1681 Returns the result of cyclically permuting the bit field in @var{fx1}
1682 with start and end positions @var{fx2} and @var{fx3} by @var{fx4} bits
1683 in the direction of more significant bits.
1684 @end deffn
1685
1686 @deffn {Scheme Procedure} fxreverse-bit-field fx1 fx2 fx3
1687 Returns the result of reversing the order of the bits of @var{fx1}
1688 between position @var{fx2} (inclusive) and position @var{fx3}
1689 (exclusive).
1690 @end deffn
1691
1692 @node rnrs arithmetic flonums
1693 @subsubsection rnrs arithmetic flonums
1694
1695 The @code{(rnrs arithmetic flonums (6))} library provides procedures for
1696 performing arithmetic operations on inexact representations of real
1697 numbers, which R6RS refers to as @dfn{flonums}.
1698
1699 Unless otherwise specified, all of the procedures below take flonums as
1700 arguments, and will raise an @code{&assertion} condition if passed a
1701 non-flonum argument.
1702
1703 @deffn {Scheme Procedure} flonum? obj
1704 Returns @code{#t} if @var{obj} is a flonum, @code{#f} otherwise.
1705 @end deffn
1706
1707 @deffn {Scheme Procedure} real->flonum x
1708 Returns the flonum that is numerically closest to the real number
1709 @var{x}.
1710 @end deffn
1711
1712 @deffn {Scheme Procedure} fl=? fl1 fl2 fl3 ...
1713 @deffnx {Scheme Procedure} fl<? fl1 fl2 fl3 ...
1714 @deffnx {Scheme Procedure} fl<=? fl1 fl2 fl3 ...
1715 @deffnx {Scheme Procedure} fl>? fl1 fl2 fl3 ...
1716 @deffnx {Scheme Procedure} fl>=? fl1 fl2 fl3 ...
1717 These procedures return @code{#t} if their flonum arguments are
1718 (respectively): equal, monotonically increasing, monotonically
1719 decreasing, monotonically nondecreasing, or monotonically nonincrasing;
1720 @code{#f} otherwise.
1721 @end deffn
1722
1723 @deffn {Scheme Procedure} flinteger? fl
1724 @deffnx {Scheme Procedure} flzero? fl
1725 @deffnx {Scheme Procedure} flpositive? fl
1726 @deffnx {Scheme Procedure} flnegative? fl
1727 @deffnx {Scheme Procedure} flodd? fl
1728 @deffnx {Scheme Procedure} fleven? fl
1729 These numerical predicates return @code{#t} if @var{fl} is,
1730 respectively, an integer, zero, greater than zero, less than zero, odd,
1731 even, @code{#f} otherwise. In the case of @code{flodd?} and
1732 @code{fleven?}, @var{fl} must be an integer-valued flonum.
1733 @end deffn
1734
1735 @deffn {Scheme Procedure} flfinite? fl
1736 @deffnx {Scheme Procedure} flinfinite? fl
1737 @deffnx {Scheme Procedure} flnan? fl
1738 These numerical predicates return @code{#t} if @var{fl} is,
1739 respectively, not infinite, infinite, or a @code{NaN} value.
1740 @end deffn
1741
1742 @deffn {Scheme Procedure} flmax fl1 fl2 ...
1743 @deffnx {Scheme Procedure} flmin fl1 fl2 ...
1744 These procedures return the maximum or minimum of their arguments.
1745 @end deffn
1746
1747 @deffn {Scheme Procedure} fl+ fl1 ...
1748 @deffnx {Scheme Procedure} fl* fl ...
1749 These procedures return the sum or product of their arguments.
1750 @end deffn
1751
1752 @deffn {Scheme Procedure} fl- fl1 fl2 ...
1753 @deffnx {Scheme Procedure} fl- fl
1754 @deffnx {Scheme Procedure} fl/ fl1 fl2 ...
1755 @deffnx {Scheme Procedure} fl/ fl
1756 These procedures return, respectively, the difference or quotient of
1757 their arguments when called with two arguments; when called with a
1758 single argument, they return the additive or multiplicative inverse of
1759 @var{fl}.
1760 @end deffn
1761
1762 @deffn {Scheme Procedure} flabs fl
1763 Returns the absolute value of @var{fl}.
1764 @end deffn
1765
1766 @deffn {Scheme Procedure} fldiv-and-mod fl1 fl2
1767 @deffnx {Scheme Procedure} fldiv fl1 fl2
1768 @deffnx {Scheme Procedure} fldmod fl1 fl2
1769 @deffnx {Scheme Procedure} fldiv0-and-mod0 fl1 fl2
1770 @deffnx {Scheme Procedure} fldiv0 fl1 fl2
1771 @deffnx {Scheme Procedure} flmod0 fl1 fl2
1772 These procedures implement number-theoretic division on flonums;
1773 @xref{(rnrs base)}, for a description for their semantics.
1774 @end deffn
1775
1776 @deffn {Scheme Procedure} flnumerator fl
1777 @deffnx {Scheme Procedure} fldenominator fl
1778 These procedures return the numerator or denominator of @var{fl} as a
1779 flonum.
1780 @end deffn
1781
1782 @deffn {Scheme Procedure} flfloor fl1
1783 @deffnx {Scheme Procedure} flceiling fl
1784 @deffnx {Scheme Procedure} fltruncate fl
1785 @deffnx {Scheme Procedure} flround fl
1786 These procedures are identical to the @code{floor}, @code{ceiling},
1787 @code{truncate}, and @code{round} procedures provided by Guile's core
1788 library. @xref{Arithmetic}, for documentation.
1789 @end deffn
1790
1791 @deffn {Scheme Procedure} flexp fl
1792 @deffnx {Scheme Procedure} fllog fl
1793 @deffnx {Scheme Procedure} fllog fl1 fl2
1794 @deffnx {Scheme Procedure} flsin fl
1795 @deffnx {Scheme Procedure} flcos fl
1796 @deffnx {Scheme Procedure} fltan fl
1797 @deffnx {Scheme Procedure} flasin fl
1798 @deffnx {Scheme Procedure} flacos fl
1799 @deffnx {Scheme Procedure} flatan fl
1800 @deffnx {Scheme Procedure} flatan fl1 fl2
1801 These procedures, which compute the usual transcendental functions, are
1802 the flonum variants of the procedures provided by the R6RS base library
1803 (@pxref{(rnrs base)}).
1804 @end deffn
1805
1806 @deffn {Scheme Procedure} flsqrt fl
1807 Returns the square root of @var{fl}. If @var{fl} is @code{-0.0},
1808 @var{-0.0} is returned; for other negative values, a @code{NaN} value
1809 is returned.
1810 @end deffn
1811
1812 @deffn {Scheme Procedure} flexpt fl1 fl2
1813 Returns the value of @var{fl1} raised to the power of @var{fl2}.
1814 @end deffn
1815
1816 The following condition types are provided to allow Scheme
1817 implementations that do not support infinities or @code{NaN} values
1818 to indicate that a computation resulted in such a value. Guile supports
1819 both of these, so these conditions will never be raised by Guile's
1820 standard libraries implementation.
1821
1822 @deffn {Condition Type} &no-infinities
1823 @deffnx {Scheme Procedure} make-no-infinities-violation obj
1824 @deffnx {Scheme Procedure} no-infinities-violation?
1825 A condition type indicating that a computation resulted in an infinite
1826 value on a Scheme implementation incapable of representing infinities.
1827 @end deffn
1828
1829 @deffn {Condition Type} &no-nans
1830 @deffnx {Scheme Procedure} make-no-nans-violation obj
1831 @deffnx {Scheme Procedure} no-nans-violation? obj
1832 A condition type indicating that a computation resulted in a @code{NaN}
1833 value on a Scheme implementation incapable of representing @code{NaN}s.
1834 @end deffn
1835
1836 @deffn {Scheme Procedure} fixnum->flonum fx
1837 Returns the flonum that is numerically closest to the fixnum @var{fx}.
1838 @end deffn
1839
1840 @node rnrs arithmetic bitwise
1841 @subsubsection rnrs arithmetic bitwise
1842
1843 The @code{(rnrs arithmetic bitwise (6))} library provides procedures for
1844 performing bitwise arithmetic operations on the two's complement
1845 representations of fixnums.
1846
1847 This library and the procedures it exports share functionality with
1848 SRFI-60, which provides support for bitwise manipulation of integers
1849 (@pxref{SRFI-60}).
1850
1851 @deffn {Scheme Procedure} bitwise-not ei
1852 @deffnx {Scheme Procedure} bitwise-and ei1 ...
1853 @deffnx {Scheme Procedure} bitwise-ior ei1 ...
1854 @deffnx {Scheme Procedure} bitwise-xor ei1 ...
1855 These procedures are identical to the @code{lognot}, @code{logand},
1856 @code{logior}, and @code{logxor} procedures provided by Guile's core
1857 library. @xref{Bitwise Operations}, for documentation.
1858 @end deffn
1859
1860 @deffn {Scheme Procedure} bitwise-if ei1 ei2 ei3
1861 Returns the bitwise ``if'' of its arguments. The bit at position
1862 @code{i} in the return value will be the @code{i}th bit from @var{ei2}
1863 if the @code{i}th bit of @var{ei1} is 1, the @code{i}th bit from
1864 @var{ei3}.
1865 @end deffn
1866
1867 @deffn {Scheme Procedure} bitwise-bit-count ei
1868 Returns the number of 1 bits in the two's complement representation of
1869 @var{ei}.
1870 @end deffn
1871
1872 @deffn {Scheme Procedure} bitwise-length ei
1873 Returns the number of bits necessary to represent @var{ei}.
1874 @end deffn
1875
1876 @deffn {Scheme Procedure} bitwise-first-bit-set ei
1877 Returns the index of the least significant 1 bit in the two's complement
1878 representation of @var{ei}.
1879 @end deffn
1880
1881 @deffn {Scheme Procedure} bitwise-bit-set? ei1 ei2
1882 Returns @code{#t} if the @var{ei2}th bit in the two's complement
1883 representation of @var{ei1} is 1, @code{#f} otherwise.
1884 @end deffn
1885
1886 @deffn {Scheme Procedure} bitwise-copy-bit ei1 ei2 ei3
1887 Returns the result of setting the @var{ei2}th bit of @var{ei1} to the
1888 @var{ei2}th bit of @var{ei3}.
1889 @end deffn
1890
1891 @deffn {Scheme Procedure} bitwise-bit-field ei1 ei2 ei3
1892 Returns the integer representation of the contiguous sequence of bits in
1893 @var{ei1} that starts at position @var{ei2} (inclusive) and ends at
1894 position @var{ei3} (exclusive).
1895 @end deffn
1896
1897 @deffn {Scheme Procedure} bitwise-copy-bit-field ei1 ei2 ei3 ei4
1898 Returns the result of replacing the bit field in @var{ei1} with start
1899 and end positions @var{ei2} and @var{ei3} with the corresponding bit
1900 field from @var{ei4}.
1901 @end deffn
1902
1903 @deffn {Scheme Procedure} bitwise-arithmetic-shift ei1 ei2
1904 @deffnx {Scheme Procedure} bitwise-arithmetic-shift-left ei1 ei2
1905 @deffnx {Scheme Procedure} bitwise-arithmetic-shift-right ei1 ei2
1906 Returns the result of shifting the bits of @var{ei1} right or left by
1907 the @var{ei2} positions. @code{bitwise-arithmetic-shift} is identical
1908 to @code{bitwise-arithmetic-shift-left}.
1909 @end deffn
1910
1911 @deffn {Scheme Procedure} bitwise-rotate-bit-field ei1 ei2 ei3 ei4
1912 Returns the result of cyclically permuting the bit field in @var{ei1}
1913 with start and end positions @var{ei2} and @var{ei3} by @var{ei4} bits
1914 in the direction of more significant bits.
1915 @end deffn
1916
1917 @deffn {Scheme Procedure} bitwise-reverse-bit-field ei1 ei2 ei3
1918 Returns the result of reversing the order of the bits of @var{e1}
1919 between position @var{ei2} (inclusive) and position @var{ei3}
1920 (exclusive).
1921 @end deffn
1922
1923 @node rnrs syntax-case
1924 @subsubsection rnrs syntax-case
1925
1926 The @code{(rnrs syntax-case (6))} library provides access to the
1927 @code{syntax-case} system for writing hygienic macros. With one
1928 exception, all of the forms and procedures exported by this library
1929 are ``re-exports'' of Guile's native support for @code{syntax-case};
1930 @xref{Syntax Case}, for documentation, examples, and rationale.
1931
1932 @deffn {Scheme Procedure} make-variable-transformer proc
1933 Creates a new variable transformer out of @var{proc}, a procedure that
1934 takes a syntax object as input and returns a syntax object. If an
1935 identifier to which the result of this procedure is bound appears on the
1936 left-hand side of a @code{set!} expression, @var{proc} will be called
1937 with a syntax object representing the entire @code{set!} expression,
1938 and its return value will replace that @code{set!} expression.
1939 @end deffn
1940
1941 @deffn {Scheme Syntax} syntax-case expression (literal ...) clause ...
1942 The @code{syntax-case} pattern matching form.
1943 @end deffn
1944
1945 @deffn {Scheme Syntax} syntax template
1946 @deffnx {Scheme Syntax} quasisyntax template
1947 @deffnx {Scheme Syntax} unsyntax template
1948 @deffnx {Scheme Syntax} unsyntax-splicing template
1949 These forms allow references to be made in the body of a syntax-case
1950 output expression subform to datum and non-datum values. They are
1951 identical to the forms provided by Guile's core library;
1952 @xref{Syntax Case}, for documentation.
1953 @end deffn
1954
1955 @deffn {Scheme Procedure} identifier? obj
1956 @deffnx {Scheme Procedure} bound-identifier=? id1 id2
1957 @deffnx {Scheme Procedure} free-identifier=? id1 id2
1958 These predicate procedures operate on syntax objects representing
1959 Scheme identifiers. @code{identifier?} returns @code{#t} if @var{obj}
1960 represents an identifier, @code{#f} otherwise.
1961 @code{bound-identifier=?} returns @code{#t} if and only if a binding for
1962 @var{id1} would capture a reference to @var{id2} in the transformer's
1963 output, or vice-versa. @code{free-identifier=?} returns @code{#t} if
1964 and only @var{id1} and @var{id2} would refer to the same binding in the
1965 output of the transformer, independent of any bindings introduced by the
1966 transformer.
1967 @end deffn
1968
1969 @deffn {Scheme Procedure} generate-temporaries l
1970 Returns a list, of the same length as @var{l}, which must be a list or
1971 a syntax object representing a list, of globally unique symbols.
1972 @end deffn
1973
1974 @deffn {Scheme Procedure} syntax->datum syntax-object
1975 @deffnx {Scheme Procedure} datum->syntax template-id datum
1976 These procedures convert wrapped syntax objects to and from Scheme datum
1977 values. The syntax object returned by @code{datum->syntax} shares
1978 contextual information with the syntax object @var{template-id}.
1979 @end deffn
1980
1981 @deffn {Scheme Procedure} syntax-violation whom message form
1982 @deffnx {Scheme Procedure} syntax-violation whom message form subform
1983 Constructs a new compound condition that includes the following
1984 simple conditions:
1985 @itemize @bullet
1986 @item
1987 If @var{whom} is not @code{#f}, a @code{&who} condition with the
1988 @var{whom} as its field
1989 @item
1990 A @code{&message} condition with the specified @var{message}
1991 @item
1992 A @code{&syntax} condition with the specified @var{form} and optional
1993 @var{subform} fields
1994 @end itemize
1995 @end deffn
1996
1997 @node rnrs hashtables
1998 @subsubsection rnrs hashtables
1999
2000 The @code{(rnrs hashtables (6))} library provides structures and
2001 procedures for creating and accessing hash tables. The hash tables API
2002 defined by R6RS is substantially similar to both Guile's native hash
2003 tables implementation as well as the one provided by SRFI-69;
2004 @xref{Hash Tables}, and @ref{SRFI-69}, respectively. Note that you can
2005 write portable R6RS library code that manipulates SRFI-69 hash tables
2006 (by importing the @code{(srfi :69)} library); however, hash tables
2007 created by one API cannot be used by another.
2008
2009 Like SRFI-69 hash tables---and unlike Guile's native ones---R6RS hash
2010 tables associate hash and equality functions with a hash table at the
2011 time of its creation. Additionally, R6RS allows for the creation
2012 (via @code{hashtable-copy}; see below) of immutable hash tables.
2013
2014 @deffn {Scheme Procedure} make-eq-hashtable
2015 @deffnx {Scheme Procedure} make-eq-hashtable k
2016 Returns a new hash table that uses @code{eq?} to compare keys and
2017 Guile's @code{hashq} procedure as a hash function. If @var{k} is given,
2018 it specifies the initial capacity of the hash table.
2019 @end deffn
2020
2021 @deffn {Scheme Procedure} make-eqv-hashtable
2022 @deffnx {Scheme Procedure} make-eqv-hashtable k
2023 Returns a new hash table that uses @code{eqv?} to compare keys and
2024 Guile's @code{hashv} procedure as a hash function. If @var{k} is given,
2025 it specifies the initial capacity of the hash table.
2026 @end deffn
2027
2028 @deffn {Scheme Procedure} make-hashtable hash-function equiv
2029 @deffnx {Scheme Procedure} make-hashtable hash-function equiv k
2030 Returns a new hash table that uses @var{equiv} to compare keys and
2031 @var{hash-function} as a hash function. @var{equiv} must be a procedure
2032 that accepts two arguments and returns a true value if they are
2033 equivalent, @code{#f} otherwise; @var{hash-function} must be a procedure
2034 that accepts one argument and returns a non-negative integer.
2035
2036 If @var{k} is given, it specifies the initial capacity of the hash
2037 table.
2038 @end deffn
2039
2040 @deffn {Scheme Procedure} hashtable? obj
2041 Returns @code{#t} if @var{obj} is an R6RS hash table, @code{#f}
2042 otherwise.
2043 @end deffn
2044
2045 @deffn {Scheme Procedure} hashtable-size hashtable
2046 Returns the number of keys currently in the hash table @var{hashtable}.
2047 @end deffn
2048
2049 @deffn {Scheme Procedure} hashtable-ref hashtable key default
2050 Returns the value associated with @var{key} in the hash table
2051 @var{hashtable}, or @var{default} if none is found.
2052 @end deffn
2053
2054 @deffn {Scheme Procedure} hashtable-set! hashtable key obj
2055 Associates the key @var{key} with the value @var{obj} in the hash table
2056 @var{hashtable}, and returns an unspecified value. An @code{&assertion}
2057 condition is raised if @var{hashtable} is immutable.
2058 @end deffn
2059
2060 @deffn {Scheme Procedure} hashtable-delete! hashtable key
2061 Removes any association found for the key @var{key} in the hash table
2062 @var{hashtable}, and returns an unspecified value. An @code{&assertion}
2063 condition is raised if @var{hashtable} is immutable.
2064 @end deffn
2065
2066 @deffn {Scheme Procedure} hashtable-contains? hashtable key
2067 Returns @code{#t} if the hash table @var{hashtable} contains an
2068 association for the key @var{key}, @code{#f} otherwise.
2069 @end deffn
2070
2071 @deffn {Scheme Procedure} hashtable-update! hashtable key proc default
2072 Associates with @var{key} in the hash table @var{hashtable} the result
2073 of calling @var{proc}, which must be a procedure that takes one
2074 argument, on the value currently associated @var{key} in
2075 @var{hashtable}---or on @var{default} if no such association exists.
2076 An @code{&assertion} condition is raised if @var{hashtable} is
2077 immutable.
2078 @end deffn
2079
2080 @deffn {Scheme Procedure} hashtable-copy hashtable
2081 @deffnx {Scheme Procedure} hashtable-copy hashtable mutable
2082 Returns a copy of the hash table @var{hashtable}. If the optional
2083 argument @var{mutable} is a true value, the new hash table will be
2084 immutable.
2085 @end deffn
2086
2087 @deffn {Scheme Procedure} hashtable-clear! hashtable
2088 @deffnx {Scheme Procedure} hashtable-clear! hashtable k
2089 Removes all of the associations from the hash table @var{hashtable}.
2090 The optional argument @var{k}, which specifies a new capacity for the
2091 hash table, is accepted by Guile's @code{(rnrs hashtables)}
2092 implementation, but is ignored.
2093 @end deffn
2094
2095 @deffn {Scheme Procedure} hashtable-keys hashtable
2096 Returns a vector of the keys with associations in the hash table
2097 @var{hashtable}, in an unspecified order.
2098 @end deffn
2099
2100 @deffn {Scheme Procedure} hashtable-entries hashtable
2101 Return two values---a vector of the keys with associations in the hash
2102 table @var{hashtable}, and a vector of the values to which these keys
2103 are mapped, in corresponding but unspecified order.
2104 @end deffn
2105
2106 @deffn {Scheme Procedure} hashtable-equivalence-function hashtable
2107 Returns the equivalence predicated use by @var{hashtable}. This
2108 procedure returns @code{eq?} and @code{eqv?}, respectively, for hash
2109 tables created by @code{make-eq-hashtable} and
2110 @code{make-eqv-hashtable}.
2111 @end deffn
2112
2113 @deffn {Scheme Procedure} hashtable-hash-function hashtable
2114 Returns the hash function used by @var{hashtable}. For hash tables
2115 created by @code{make-eq-hashtable} or @code{make-eqv-hashtable},
2116 @code{#f} is returned.
2117 @end deffn
2118
2119 @deffn {Scheme Procedure} hashtable-mutable? hashtable
2120 Returns @code{#t} if @var{hashtable} is mutable, @code{#f} otherwise.
2121 @end deffn
2122
2123 A number of hash functions are provided for convenience:
2124
2125 @deffn {Scheme Procedure} equal-hash obj
2126 Returns an integer hash value for @var{obj}, based on its structure and
2127 current contents. This hash function is suitable for use with
2128 @code{equal?} as an equivalence function.
2129 @end deffn
2130
2131 @deffn {Scheme Procedure} string-hash string
2132 @deffnx {Scheme Procedure} symbol-hash symbol
2133 These procedures are identical to the ones provided by Guile's core
2134 library. @xref{Hash Table Reference}, for documentation.
2135 @end deffn
2136
2137 @deffn {Scheme Procedure} string-ci-hash string
2138 Returns an integer hash value for @var{string} based on its contents,
2139 ignoring case. This hash function is suitable for use with
2140 @code{string-ci=?} as an equivalence function.
2141 @end deffn
2142
2143 @node rnrs enums
2144 @subsubsection rnrs enums
2145
2146 The @code{(rnrs enums (6))} library provides structures and procedures
2147 for working with enumerable sets of symbols. Guile's implementation
2148 defines an @dfn{enum-set} record type that encapsulates a finite set of
2149 distinct symbols, the @dfn{universe}, and a subset of these symbols,
2150 which define the enumeration set.
2151
2152 The SRFI-1 list library provides a number of procedures for performing
2153 set operations on lists; Guile's @code{(rnrs enums)} implementation
2154 makes use of several of them. @xref{SRFI-1 Set Operations}, for
2155 more information.
2156
2157 @deffn {Scheme Procedure} make-enumeration symbol-list
2158 Returns a new enum-set whose universe and enumeration set are both equal
2159 to @var{symbol-list}, a list of symbols.
2160 @end deffn
2161
2162 @deffn {Scheme Procedure} enum-set-universe enum-set
2163 Returns an enum-set representing the universe of @var{enum-set},
2164 an enum-set.
2165 @end deffn
2166
2167 @deffn {Scheme Procedure} enum-set-indexer enum-set
2168 Returns a procedure that takes a single argument and returns the
2169 zero-indexed position of that argument in the universe of
2170 @var{enum-set}, or @code{#f} if its argument is not a member of that
2171 universe.
2172 @end deffn
2173
2174 @deffn {Scheme Procedure} enum-set-constructor enum-set
2175 Returns a procedure that takes a single argument, a list of symbols
2176 from the universe of @var{enum-set}, an enum-set, and returns a new
2177 enum-set with the same universe that represents a subset containing the
2178 specified symbols.
2179 @end deffn
2180
2181 @deffn {Scheme Procedure} enum-set->list enum-set
2182 Returns a list containing the symbols of the set represented by
2183 @var{enum-set}, an enum-set, in the order that they appear in the
2184 universe of @var{enum-set}.
2185 @end deffn
2186
2187 @deffn {Scheme Procedure} enum-set-member? symbol enum-set
2188 @deffnx {Scheme Procedure} enum-set-subset? enum-set1 enum-set2
2189 @deffnx {Scheme Procedure} enum-set=? enum-set1 enum-set2
2190 These procedures test for membership of symbols and enum-sets in other
2191 enum-sets. @code{enum-set-member?} returns @code{#t} if and only if
2192 @var{symbol} is a member of the subset specified by @var{enum-set}.
2193 @code{enum-set-subset?} returns @code{#t} if and only if the universe of
2194 @var{enum-set1} is a subset of the universe of @var{enum-set2} and
2195 every symbol in @var{enum-set1} is present in @var{enum-set2}.
2196 @code{enum-set=?} returns @code{#t} if and only if @var{enum-set1} is a
2197 subset, as per @code{enum-set-subset?} of @var{enum-set2} and vice
2198 versa.
2199 @end deffn
2200
2201 @deffn {Scheme Procedure} enum-set-union enum-set1 enum-set2
2202 @deffnx {Scheme Procedure} enum-set-intersection enum-set1 enum-set2
2203 @deffnx {Scheme Procedure} enum-set-difference enum-set1 enum-set2
2204 These procedures return, respectively, the union, intersection, and
2205 difference of their enum-set arguments.
2206 @end deffn
2207
2208 @deffn {Scheme Procedure} enum-set-complement enum-set
2209 Returns @var{enum-set}'s complement (an enum-set), with regard to its
2210 universe.
2211 @end deffn
2212
2213 @deffn {Scheme Procedure} enum-set-projection enum-set1 enum-set2
2214 Returns the projection of the enum-set @var{enum-set1} onto the universe
2215 of the enum-set @var{enum-set2}.
2216 @end deffn
2217
2218 @deffn {Scheme Syntax} define-enumeration type-name (symbol ...) constructor-syntax
2219 Evaluates to two new definitions: A constructor bound to
2220 @var{constructor-syntax} that behaves similarly to constructors created
2221 by @code{enum-set-constructor}, above, and creates new @var{enum-set}s
2222 in the universe specified by @code{(symbol ...)}; and a ``predicate
2223 macro'' bound to @var{type-name}, which has the following form:
2224
2225 @lisp
2226 (@var{type-name} sym)
2227 @end lisp
2228
2229 If @var{sym} is a member of the universe specified by the @var{symbol}s
2230 above, this form evaluates to @var{sym}. Otherwise, a @code{&syntax}
2231 condition is raised.
2232 @end deffn
2233
2234 @node rnrs
2235 @subsubsection rnrs
2236
2237 The @code{(rnrs (6))} library is a composite of all of the other R6RS
2238 standard libraries---it imports and re-exports all of their exported
2239 procedures and syntactic forms---with the exception of the following
2240 libraries:
2241
2242 @itemize @bullet
2243 @item @code{(rnrs eval (6))}
2244 @item @code{(rnrs mutable-pairs (6))}
2245 @item @code{(rnrs mutable-strings (6))}
2246 @item @code{(rnrs r5rs (6))}
2247 @end itemize
2248
2249 @node rnrs eval
2250 @subsubsection rnrs eval
2251
2252 The @code{(rnrs eval (6)} library provides procedures for performing
2253 ``on-the-fly'' evaluation of expressions.
2254
2255 @deffn {Scheme Procedure} eval expression environment
2256 Evaluates @var{expression}, which must be a datum representation of a
2257 valid Scheme expression, in the environment specified by
2258 @var{environment}. This procedure is identical to the one provided by
2259 Guile's code library; @xref{Fly Evaluation}, for documentation.
2260 @end deffn
2261
2262 @deffn {Scheme Procedure} environment import-spec ...
2263 Constructs and returns a new environment based on the specified
2264 @var{import-spec}s, which must be datum representations of the import
2265 specifications used with the @code{import} form. @xref{R6RS Libraries},
2266 for documentation.
2267 @end deffn
2268
2269 @node rnrs mutable-pairs
2270 @subsubsection rnrs mutable-pairs
2271
2272 The @code{(rnrs mutable-pairs (6))} library provides the @code{set-car!}
2273 and @code{set-cdr!} procedures, which allow the @code{car} and
2274 @code{cdr} fields of a pair to be modified.
2275
2276 These procedures are identical to the ones provide by Guile's core
2277 library. @xref{Pairs}, for documentation. All pairs in Guile are
2278 mutable; consequently, these procedures will never throw the
2279 @code{&assertion} condition described in the R6RS libraries
2280 specification.
2281
2282 @node rnrs mutable-strings
2283 @subsubsection rnrs mutable-strings
2284
2285 The @code{(rnrs mutable-strings (6))} library provides the
2286 @code{string-set!} and @code{string-fill!} procedures, which allow the
2287 content of strings to be modified ``in-place.''
2288
2289 These procedures are identical to the ones provided by Guile's core
2290 library. @xref{String Modification}, for documentation. All strings in
2291 Guile are mutable; consequently, these procedures will never throw the
2292 @code{&assertion} condition described in the R6RS libraries
2293 specification.
2294
2295 @node rnrs r5rs
2296 @subsubsection rnrs r5rs
2297
2298 The @code{(rnrs r5rs (6))} library exports bindings for some procedures
2299 present in R5RS but omitted from the R6RS base library specification.
2300
2301 @deffn {Scheme Procedure} exact->inexact z
2302 @deffnx {Scheme Procedure} inexact->exact z
2303 These procedures are identical to the ones provided by Guile's core
2304 library. @xref{Exactness}, for documentation.
2305 @end deffn
2306
2307 @deffn {Scheme Procedure} quotient n1 n2
2308 @deffnx {Scheme Procedure} remainder n1 n2
2309 @deffnx {Scheme Procedure} modulo n1 n2
2310 These procedures are identical to the ones provided by Guile's core
2311 library. @xref{Integer Operations}, for documentation.
2312 @end deffn
2313
2314 @deffn {Scheme Syntax} delay expr
2315 @deffnx {Scheme Procedure} force promise
2316 The @code{delay} form and the @code{force} procedure are identical to
2317 their counterparts in Guile's core library. @xref{Delayed Evaluation},
2318 for documentation.
2319 @end deffn
2320
2321 @deffn {Scheme Procedure} null-environment n
2322 @deffnx {Scheme Procedure} scheme-report-environment n
2323 These procedures are identical to the ones provided by the
2324 @code{(ice-9 r5rs)} Guile module. @xref{Environments}, for
2325 documentation.
2326 @end deffn
2327
2328 @c r6rs.texi ends here
2329
2330 @c Local Variables:
2331 @c TeX-master: "guile.texi"
2332 @c End: