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