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