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