r7rs-small-texinfo

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 867f24ca42703d1a23ac1006f7b4904c7aacfd93
parent 015d6637a5c7a929c8448d7fcdb64760d59d401b
Author: Wolfgang Corcoran-Mathe <wcm@sigwinch.xyz>
Date:   Mon, 29 Jan 2024 21:20:59 -0500

Use @deffn for procedures, part 1.

There are several unclosed @deffns. I'll get to them.

Diffstat:
Mdoc/r7rs-small/r7rs-small.texinfo | 997++++++++++++++++++++++++++++++++++++++-----------------------------------------
1 file changed, 476 insertions(+), 521 deletions(-)

diff --git a/doc/r7rs-small/r7rs-small.texinfo b/doc/r7rs-small/r7rs-small.texinfo @@ -422,7 +422,7 @@ template for a call to the procedure. Argument names in the template are italicized. Thus the header line -procedure: (vector-ref vector k) +@deffn procedure vector-ref vector k indicates that the procedure bound to the @code{vector-ref} variable takes two arguments, a @@ -432,10 +432,10 @@ vector @var{k} (see below). The header lines -procedure: (make-vector k) +@deffn procedure make-vector k -procedure: (make-vector k fill) +@deffn procedure make-vector k fill indicate that the @code{make-vector} procedure must be defined to take either one or two @@ -785,8 +785,8 @@ For a description of the notations used for numbers, see section 6.2. @node Datum labels @section Datum labels -lexical syntax: #<n>=<datum> -lexical syntax: #<n># +@deffn {lexical syntax} #<n>=<datum> +@deffnx {lexical syntax} #<n># The lexical syntax @code{#}<n>@code{=}<datum> reads the same as <datum>, but also results in <datum> being labelled by <n>. It is an error if <n> is not a sequence of digits. @@ -817,6 +817,7 @@ In particular, it is an error for quasiquote (section 4.2.8) to contain them. #1=(begin (display #\x) #1#) @result{} @error{} @end example +@end deffn @node Basic concepts @chapter Basic concepts @@ -2049,21 +2050,19 @@ are supported in some implementations: @end example -lazy library procedure: (promise? obj) - +@deffn {lazy library procedure} promise? obj The promise? procedure returns #t if its argument is a promise, and #f otherwise. Note that promises are not necessarily disjoint from other Scheme types such as procedures. +@end deffn -lazy library procedure: (make-promise obj) - +@deffn {lazy library procedure} make-promise obj The make-promise procedure returns a promise which, when forced, will return - -obj. It is similar to delay, but does not delay its argument: it is a procedure rather than +@var{obj}. It is similar to delay, but does not delay its argument: it is a procedure rather than syntax. If - -obj is already a promise, it is returned. +@var{obj} is already a promise, it is returned. +@end deffn @node Dynamic bindings @subsection Dynamic bindings @@ -2077,23 +2076,18 @@ This sections introduces parameter objects, which can be bound to new values for duration of a dynamic extent. The set of all parameter bindings at a given time is called the dynamic environment. -procedure: (make-parameter init) -procedure: (make-parameter init converter) +@deffn procedure make-parameter init +@deffnx procedure make-parameter init converter Returns a newly allocated parameter object, which is a procedure that accepts zero arguments and returns the value associated with the parameter object. Initially, this value -is the value of ( - -converter - -init), or of - -init if the conversion procedure - -converter is not specified. The associated value can be temporarily changed using +is the value of @code{(@var{converter} @var{init})}, or of +@var{init} if the conversion procedure +@var{converter} is not specified. The associated value can be temporarily changed using parameterize, which is described below. The effect of passing arguments to a parameter object is implementation-dependent. +@end deffn syntax: (parameterize ((<param1> <value1>) @dots{}) <body>) @@ -3250,111 +3244,111 @@ symmetric, reflexive, and transitive. Of the equivalence predicates described in section, eq? is the finest or most discriminating, equal? is the coarsest, and eqv? is slightly less discriminating than eq?. -procedure: (eqv? obj1 obj2) +@deffn procedure eqv? obj1 obj2 -The eqv? procedure defines a useful equivalence relation on objects. Briefly, it returns #t +The @code{eqv?} procedure defines a useful equivalence relation on objects. Briefly, it returns #t if -obj1 and obj2 are normally regarded as the same object. This relation is left slightly open to -interpretation, but the following partial specification of eqv? holds for all implementations +@var{obj1} and @var{obj2} are normally regarded as the same object. This relation is left slightly open to +interpretation, but the following partial specification of @code{eqv?} holds for all implementations of Scheme. -The eqv? procedure returns #t if: +The @code{eqv?} procedure returns #t if: -* obj1 and +* @var{obj1} and - obj2 are both #t or both #f. + @var{obj2} are both #t or both #f. -* obj1 and +* @var{obj1} and - obj2 are both symbols and are the same symbol according to the symbol=? procedure + @var{obj2} are both symbols and are the same symbol according to the symbol=? procedure (section 6.5). -* obj1 and +* @var{obj1} and - obj2 are both exact numbers and are numerically equal (in the sense of =). + @var{obj2} are both exact numbers and are numerically equal (in the sense of =). -* obj1 and +* @var{obj1} and - obj2 are both inexact numbers such that they are numerically equal (in the sense of =) - and they yield the same results (in the sense of eqv?) when passed as arguments to any + @var{obj2} are both inexact numbers such that they are numerically equal (in the sense of =) + and they yield the same results (in the sense of @code{eqv?}) when passed as arguments to any other procedure that can be defined as a finite composition of Scheme's standard arithmetic procedures, provided it does not result in a NaN value. -* obj1 and +* @var{obj1} and - obj2 are both characters and are the same character according to the char=? procedure + @var{obj2} are both characters and are the same character according to the char=? procedure (section 6.6). -* obj1 and +* @var{obj1} and - obj2 are both the empty list. + @var{obj2} are both the empty list. -* obj1 and +* @var{obj1} and - obj2 are pairs, vectors, bytevectors, records, or strings that denote the same location in + @var{obj2} are pairs, vectors, bytevectors, records, or strings that denote the same location in the store (section 3.4). -* obj1 and +* @var{obj1} and - obj2 are procedures whose location tags are equal (section 4.1.4). + @var{obj2} are procedures whose location tags are equal (section 4.1.4). -The eqv? procedure returns #f if: +The @code{eqv?} procedure returns #f if: -* obj1 and +* @var{obj1} and - obj2 are of different types (section 3.2). + @var{obj2} are of different types (section 3.2). * one of - obj1 and + @var{obj1} and - obj2 is #t but the other is #f. + @var{obj2} is #t but the other is #f. -* obj1 and +* @var{obj1} and - obj2 are symbols but are not the same symbol according to the symbol=? procedure + @var{obj2} are symbols but are not the same symbol according to the symbol=? procedure (section 6.5). * one of - obj1 and + @var{obj1} and - obj2 is an exact number but the other is an inexact number. + @var{obj2} is an exact number but the other is an inexact number. -* obj1 and +* @var{obj1} and - obj2 are both exact numbers and are numerically unequal (in the sense of =). + @var{obj2} are both exact numbers and are numerically unequal (in the sense of =). -* obj1 and +* @var{obj1} and - obj2 are both inexact numbers such that either they are numerically unequal (in the - sense of =), or they do not yield the same results (in the sense of eqv?) when passed as + @var{obj2} are both inexact numbers such that either they are numerically unequal (in the + sense of =), or they do not yield the same results (in the sense of @code{eqv?}) when passed as arguments to any other procedure that can be defined as a finite composition of Scheme's standard arithmetic procedures, provided it does not result in a NaN value. As - an exception, the behavior of eqv? is unspecified when both + an exception, the behavior of @code{eqv?} is unspecified when both - obj1 and + @var{obj1} and - obj2 are NaN. + @var{obj2} are NaN. -* obj1 and +* @var{obj1} and - obj2 are characters for which the char=? procedure returns #f. + @var{obj2} are characters for which the char=? procedure returns #f. * one of - obj1 and + @var{obj1} and - obj2 is the empty list but the other is not. + @var{obj2} is the empty list but the other is not. -* obj1 and +* @var{obj1} and - obj2 are pairs, vectors, bytevectors, records, or strings that denote distinct locations. + @var{obj2} are pairs, vectors, bytevectors, records, or strings that denote distinct locations. -* obj1 and +* @var{obj1} and - obj2 are procedures that would behave differently (return different values or have + @var{obj2} are procedures that would behave differently (return different values or have different side effects) for some arguments. @example @@ -3376,8 +3370,8 @@ The eqv? procedure returns #f if: @end example The following examples illustrate cases in which the above rules -do not fully specify the behavior of eqv?. All that can be said about such cases is that the -value returned by eqv? must be a boolean. +do not fully specify the behavior of @code{eqv?}. All that can be said about such cases is that the +value returned by @code{eqv?} must be a boolean. @example @@ -3392,14 +3386,14 @@ value returned by eqv? must be a boolean. @end example -Note that (eqv? 0.0 -0.0) will return #f if negative zero +Note that (@code{eqv?} 0.0 -0.0) will return #f if negative zero is distinguished, and #t if negative zero is not distinguished. -The next set of examples shows the use of eqv? with procedures that have local state. The +The next set of examples shows the use of @code{eqv?} with procedures that have local state. The gen-counter procedure must return a distinct procedure every time, since each procedure has its own internal counter. The gen-loser procedure, however, returns operationally equivalent procedures each time, since the local state does not affect the -value or side effects of the procedures. However, eqv? may or may not detect this +value or side effects of the procedures. However, @code{eqv?} may or may not detect this equivalence. @example @@ -3435,7 +3429,7 @@ equivalence. Since it is an error to modify constant objects (those returned by literal expressions), implementations may share structure between constants where -appropriate. Thus the value of eqv? on constants is sometimes +appropriate. Thus the value of @code{eqv?} on constants is sometimes implementation-dependent. @example @@ -3448,28 +3442,28 @@ implementation-dependent. @end example -The above definition of eqv? allows implementations latitude in +The above definition of @code{eqv?} allows implementations latitude in their treatment of procedures and literals: implementations may either detect or fail to detect that two procedures or two literals are equivalent to each other, and can decide whether or not to merge representations of equivalent objects by using the same pointer or bit pattern to represent both. Note: If inexact numbers are represented as IEEE binary floating-point numbers, then -an implementation of eqv? that simply compares equal-sized inexact numbers for +an implementation of @code{eqv?} that simply compares equal-sized inexact numbers for bitwise equality is correct by the above definition. +@end deffn -procedure: (eq? obj1 obj2) - +@deffn procedure eq? obj1 obj2 -The eq? procedure is similar to eqv? except that in some cases it is capable of discerning +The @code{eq?} procedure is similar to eqv? except that in some cases it is capable of discerning distinctions finer than those detectable by eqv?. It must always return #f when eqv? also would, but may return #f in some cases where eqv? would return #t. On symbols, booleans, the empty list, pairs, and records, and also on non-empty strings, -vectors, and bytevectors, eq? and eqv? are guaranteed to have the same behavior. On -procedures, eq? must return true if the arguments' location tags are equal. On numbers -and characters, eq?'s behavior is implementation-dependent, but it will always return -either true or false. On empty strings, empty vectors, and empty bytevectors, eq? may also +vectors, and bytevectors, @code{eq?} and eqv? are guaranteed to have the same behavior. On +procedures, @code{eq?} must return true if the arguments' location tags are equal. On numbers +and characters, @code{eq?}'s behavior is implementation-dependent, but it will always return +either true or false. On empty strings, empty vectors, and empty bytevectors, @code{eq?} may also behave differently from eqv?. @example @@ -3494,21 +3488,21 @@ behave differently from eqv?. @end example -Rationale: It will usually be possible to implement eq? much more efficiently than +Rationale: It will usually be possible to implement @code{eq?} much more efficiently than eqv?, for example, as a simple pointer comparison instead of as some more complicated operation. One reason is that it is not always possible to compute eqv? - of two numbers in constant time, whereas eq? implemented as pointer comparison + of two numbers in constant time, whereas @code{eq?} implemented as pointer comparison will always finish in constant time. -procedure: (equal? obj1 obj2) +@deffn procedure equal? obj1 obj2 -The equal? procedure, when applied to pairs, vectors, strings and bytevectors, recursively +The @code{equal?} procedure, when applied to pairs, vectors, strings and bytevectors, recursively compares them, returning #t when the unfoldings of its arguments into (possibly infinite) -trees are equal (in the sense of equal?) as ordered trees, and #f otherwise. It returns the +trees are equal (in the sense of @code{equal?}) as ordered trees, and #f otherwise. It returns the same as eqv? when applied to booleans, symbols, numbers, characters, ports, -procedures, and the empty list. If two objects are eqv?, they must be equal? as well. In all -other cases, equal? may return either #t or #f. Even if its arguments are circular data -structures, equal? must always terminate. +procedures, and the empty list. If two objects are eqv?, they must be @code{equal?} as well. In all +other cases, @code{equal?} may return either #t or #f. Even if its arguments are circular data +structures, @code{equal?} must always terminate. @example @@ -3528,6 +3522,7 @@ structures, equal? must always terminate. @end example Note: A rule of thumb is that objects are generally equal? if they print the same. +@end deffn @node Numbers @section Numbers @@ -3815,11 +3810,11 @@ numerical constants written using an inexact notation can be represented without accuracy; the inexact constants were chosen so that this is likely to be true in implementations that use IEEE binary doubles to represent inexact numbers. -procedure: (number? obj) -procedure: (complex? obj) -procedure: (real? obj) -procedure: (rational? obj) -procedure: (integer? obj) +@deffn procedure number? obj +@deffnx procedure complex? obj +@deffnx procedure real? obj +@deffnx procedure rational? obj +@deffnx procedure integer? obj These numerical type predicates can be applied to any kind of argument, including non-numbers. They return #t if the object is of the named type, and otherwise they return @@ -3873,10 +3868,8 @@ number?, but unusual implementations may represent some irrational numbers exactly or may extend the number system to support some kind of non-complex numbers. -procedure: (exact? z) - - -procedure: (inexact? z) +@deffn procedure exact? z +@deffnx procedure inexact? z These numerical predicates provide tests for the exactness of a quantity. For any Scheme @@ -3890,7 +3883,7 @@ number, precisely one of these predicates is true. @end example -procedure: (exact-integer? z) +@deffn procedure exact-integer? z Returns #t if @@ -3950,20 +3943,11 @@ imaginary parts or both are +nan.0. Otherwise it returns #f. @end example -procedure: (= z1 z2 z3 @dots{}) - - -procedure: (< x1 x2 x3 @dots{}) - - -procedure: (> x1 x2 x3 @dots{}) - - -procedure: (<= x1 x2 x3 @dots{}) - - -procedure: (>= x1 x2 x3 @dots{}) - +@deffn procedure = z1 z2 z3 @dots{} +@deffnx procedure < x1 x2 x3 @dots{} +@deffnx procedure > x1 x2 x3 @dots{} +@deffnx procedure <= x1 x2 x3 @dots{} +@deffnx procedure >= x1 x2 x3 @dots{} These procedures return #t if their arguments are (respectively): equal, monotonically increasing, monotonically decreasing, monotonically non-decreasing, or monotonically @@ -3984,30 +3968,20 @@ avoid this problem, though special care must be taken with infinities. Note: While it is not an error to compare inexact numbers using these predicates, the results are unreliable because a small inaccuracy can affect the result; this is especially true of = and zero?. When in doubt, consult a numerical analyst. +@end deffn -procedure: (zero? z) - - -procedure: (positive? x) - - -procedure: (negative? x) - - -procedure: (odd? n) - - -procedure: (even? n) - +@deffn procedure zero? z +@deffnx procedure positive? x +@deffnx procedure negative? x +@deffnx procedure odd? n +@deffnx procedure even? n These numerical predicates test a number for a particular property, returning #t or #f. See note above. +@end deffn -procedure: (max x1 x2 @dots{}) - - -procedure: (min x1 x2 @dots{}) - +@deffn procedure max x1 x2@dots{} +@deffnx procedure min x1 x2@dots{} These procedures return the maximum or minimum of their arguments. @@ -4024,12 +3998,10 @@ which is possible only in unusual implementations). If min or max is used to com numbers of mixed exactness, and the numerical value of the result cannot be represented as an inexact number without loss of accuracy, then the procedure may report a violation of an implementation restriction. +@end deffn -procedure: (+ z1 @dots{}) - - -procedure: (* z1 @dots{}) - +@deffn procedure + z1 @dots{} +@deffnx procedure * z1 @dots{} These procedures return the sum or product of their arguments. @@ -4042,18 +4014,12 @@ These procedures return the sum or product of their arguments. (*) @result{} 1 @end example +@end deffn -procedure: (- z) - - -procedure: (- z1 z2 @dots{}) - - -procedure: (/ z) - - -procedure: (/ z1 z2 @dots{}) - +@deffn procedure - z +@deffnx procedure - z1 z2@dots{} +@deffnx procedure / z +@deffnx procedure / z1 z2@dots{} With two or more arguments, these procedures return the difference or quotient of their arguments, associating to the left. With one argument, however, they return the additive @@ -4072,8 +4038,9 @@ other arguments is a NaN. (/ 3) @result{} 1/3 @end example +@end deffn -procedure: (abs x) +@deffn procedure abs x The abs procedure returns the absolute value of its argument. @@ -4082,24 +4049,14 @@ The abs procedure returns the absolute value of its argument. (abs -7) @result{} 7 @end example +@end deffn -procedure: (floor/ n1 n2) - - -procedure: (floor-quotient n1 n2) - - -procedure: (floor-remainder n1 n2) - - -procedure: (truncate/ n1 n2) - - -procedure: (truncate-quotient n1 n2) - - -procedure: (truncate-remainder n1 n2) - +@deffn procedure floor/ n1 n2 +@deffnx procedure floor-quotient n1 n2 +@deffnx procedure floor-remainder n1 n2 +@deffnx procedure truncate/ n1 n2 +@deffnx procedure truncate-quotient n1 n2 +@deffnx procedure truncate-remainder n1 n2 These procedures implement number-theoretic (integer) division. It is an error if @@ -4210,27 +4167,21 @@ Examples: (truncate/ -5.0 -2) @result{} 2.0 -1.0 @end example +@end deffn -procedure: (quotient n1 n2) - - -procedure: (remainder n1 n2) - - -procedure: (modulo n1 n2) - +@deffn procedure quotient n1 n2 +@deffnx procedure remainder n1 n2 +@deffnx procedure modulo n1 n2 The quotient and remainder procedures are equivalent to truncate-quotient and truncate-remainder, respectively, and modulo is equivalent to floor-remainder. Note: These procedures are provided for backward compatibility with earlier versions of this report. +@end deffn -procedure: (gcd n1 @dots{}) - - -procedure: (lcm n1 @dots{}) - +@deffn procedure gcd n1 @dots{} +@deffn procedure lcm n1 @dots{} These procedures return the greatest common divisor or least common multiple of their arguments. The result is always non-negative. @@ -4244,12 +4195,10 @@ arguments. The result is always non-negative. (lcm) @result{} 1 @end example +@end deffn -procedure: (numerator q) - - -procedure: (denominator q) - +@deffn procedure numerator q +@deffn procedure denominator q These procedures return the numerator or denominator of their argument; the result is computed as if the argument was represented as a fraction in lowest terms. The @@ -4264,10 +4213,10 @@ denominator is always positive. The denominator of 0 is defined to be 1. @end example -procedure: (floor x) -procedure: (ceiling x) -procedure: (truncate x) -procedure: (round x) +@deffn procedure floor x +@deffnx procedure ceiling x +@deffnx procedure truncate x +@deffnx procedure round x These procedures return integers. The floor procedure returns the largest integer not larger than @@ -4307,8 +4256,9 @@ procedure. If the argument is infinite or a NaN, then it is returned. (round 7) @result{} 7 @end example +@end deffn -procedure: (rationalize x y) +@deffn procedure rationalize x y The rationalize procedure returns the simplest rational number differing from @@ -4328,36 +4278,18 @@ rational of all. (rationalize .3 1/10) @result{} #i1/3 ; inexact @end example +@end deffn -inexact library procedure: (exp z) - - -inexact library procedure: (log z) - - -inexact library procedure: (log z1 z2) - - -inexact library procedure: (sin z) - - -inexact library procedure: (cos z) - - -inexact library procedure: (tan z) - - -inexact library procedure: (asin z) - - -inexact library procedure: (acos z) - - -inexact library procedure: (atan z) - - -inexact library procedure: (atan y x) - +@deffn {inexact library procedure} exp z +@deffnx {inexact library procedure} log z +@deffnx {inexact library procedure} log z1 z2 +@deffnx {inexact library procedure} sin z +@deffnx {inexact library procedure} cos z +@deffnx {inexact library procedure} tan z +@deffnx {inexact library procedure} asin z +@deffnx {inexact library procedure} acos z +@deffnx {inexact library procedure} atan z +@deffnx {inexact library procedure} atan y x These procedures compute the usual transcendental functions. The log procedure computes the natural logarithm of @@ -4422,9 +4354,9 @@ The above specification follows [34], which in turn cites [26]; refer to these s more detailed discussion of branch cuts, boundary conditions, and implementation of these functions. When it is possible, these procedures produce a real result from a real argument. +@end deffn -procedure: (square z) - +@deffn procedure square z Returns the square of z. This is equivalent to @code{(* z z)}. @@ -4435,8 +4367,7 @@ Returns the square of z. This is equivalent to @code{(* z z)}. @end example -inexact library procedure: (sqrt z) - +@deffn {inexact library procedure} sqrt z Returns the principal square root of @@ -4449,8 +4380,9 @@ imaginary part. (sqrt -1) @result{} +i @end example +@end deffn -procedure: (exact-integer-sqrt k) +@deffn procedure exact-integer-sqrt k Returns two non-negative exact integers s and r where @@ -4464,9 +4396,9 @@ k < (s + 1)2. (exact-integer-sqrt 5) @result{} 2 1 @end example +@end deffn -procedure: (expt z1 z2) - +@deffn procedure expt z1 z2 Returns @@ -4480,24 +4412,14 @@ z1, this is The value of 0z is 1 if (zero? z), 0 if (real-part z) is positive, and an error otherwise. Similarly for 0.0z, with inexact results. +@end deffn -complex library procedure: (make-rectangular x1 x2) - - -complex library procedure: (make-polar x3 x4) - - -complex library procedure: (real-part z) - - -complex library procedure: (imag-part z) - - -complex library procedure: (magnitude z) - - -complex library procedure: (angle z) - +@deffn {complex library procedure} make-rectangular x1 x2 +@deffnx {complex library procedure} make-polar x3 x4 +@deffnx {complex library procedure} real-part z +@deffnx {complex library procedure} imag-part z +@deffnx {complex library procedure} magnitude z +@deffnx {complex library procedure} angle z Let @@ -4539,12 +4461,10 @@ make-rectangular was exact. Rationale: The magnitude procedure is the same as abs for a real argument, but abs is in the base library, whereas magnitude is in the optional complex library. +@end deffn -procedure: (inexact z) - - -procedure: (exact z) - +@deffn procedure inexact z +@deffn procedure exact z The procedure inexact returns an inexact representation of @@ -4572,12 +4492,13 @@ inexact integers throughout an implementation-dependent range. See section 6.2.3 Note: These procedures were known in R5RS as exact->inexact and inexact->exact, respectively, but they have always accepted arguments of any exactness. The new names are clearer and shorter, as well as being compatible with R6RS. +@end deffn @node Numerical input and output @subsection Numerical input and output -procedure: (number->string z) -procedure: (number->string z radix) +@deffn procedure number->string z +@deffnx procedure number->string z radix It is an error if @@ -4620,9 +4541,10 @@ Rationale: If z is an inexact number and the radix is 10, then the above expression is normally satisfied by a result containing a decimal point. The unspecified case allows for infinities, NaNs, and unusual representations. +@end deffn -procedure: (string->number string) -procedure: (string->number string radix) +@deffn procedure string->number string +@deffnx procedure string->number string radix Returns a number of the maximally precise representation expressed by the given @@ -4670,6 +4592,7 @@ Note: The domain of string->number may be restricted by implementations in the programs. As a consequence, the R5RS permission to return #f when string has an explicit radix prefix has been withdrawn. +@end deffn @node Booleans @section Booleans @@ -4698,7 +4621,7 @@ programs. @end example -procedure: (not obj) +@deffn procedure not obj The not procedure returns #t if @@ -4715,8 +4638,9 @@ obj is false, and returns #f otherwise. (not 'nil) @result{} #f @end example +@end deffn -procedure: (boolean? obj) +@deffn procedure boolean? obj The boolean? predicate returns #t if @@ -4729,11 +4653,12 @@ obj is either #t or #f and returns #f otherwise. (boolean? '()) @result{} #f @end example +@end deffn -procedure: (boolean=? boolean1 boolean2 boolean3 @dots{}) - +@deffn procedure boolean=? boolean1 boolean2 boolean3 @dots{} Returns #t if all the arguments are #t or all are #f. +@end deffn @node Pairs and lists @section Pairs and lists @@ -4826,19 +4751,21 @@ That is, according to Scheme's grammar, every <expression> is also a <datum> (se section 7.1.2). Among other things, this permits the use of the read procedure to parse Scheme programs. See section 3.3. -procedure: (pair? obj) +@deffn procedure pair? obj The pair? predicate returns #t if obj is a pair, and otherwise returns #f. +@example (pair? '(a . b)) @result{} #t (pair? '(a b c)) @result{} #t (pair? '()) @result{} #f (pair? '#(a b)) @result{} #f +@end example +@end deffn -procedure: (cons obj1 obj2) - +@deffn procedure cons obj1 obj2 Returns a newly allocated pair whose car is @@ -4847,34 +4774,43 @@ obj1 and whose cdr is obj2. The pair is guaranteed to be different (in the sense of eqv?) from every existing object. +@example (cons 'a '()) @result{} (a) (cons '(a) '(b c d)) @result{} ((a) b c d) (cons "a" '(b c)) @result{} ("a" b c) (cons 'a 3) @result{} (a . 3) (cons '(a b) 'c) @result{} ((a b) . c) +@end example +@end deffn -procedure: (car pair) +@deffn procedure car pair Returns the contents of the car field of pair. Note that it is an error to take the car of the empty list. +@example (car '(a b c)) @result{} a (car '((a) b c d)) @result{} (a) (car '(1 . 2)) @result{} 1 (car '()) @result{} error +@end example +@end deffn -procedure: (cdr pair) +@deffn procedure cdr pair Returns the contents of the cdr field of pair. Note that it is an error to take the cdr of the empty list. +@example (cdr '((a) b c d)) @result{} (b c d) (cdr '(1 . 2)) @result{} 2 (cdr '()) @result{} error +@end example +@end deffn -procedure: (set-car! pair obj) +@deffn procedure set-car! pair obj Stores @@ -4886,19 +4822,21 @@ pair. (define (g) '(constant-list)) (set-car! (f) 3) @result{} unspecified (set-car! (g) 3) @result{} error +@end deffn -procedure: (set-cdr! pair obj) +@deffn procedure set-cdr! pair obj Stores obj in the cdr field of pair. +@end deffn -procedure: (caar pair) -procedure: (cadr pair) -procedure: (cdar pair) -procedure: (cddr pair) +@deffn procedure caar pair +@deffnx procedure cadr pair +@deffnx procedure cdar pair +@deffnx procedure cddr pair These procedures are compositions of car and cdr as follows: @@ -4910,6 +4848,7 @@ These procedures are compositions of car and cdr as follows: (define (cddr x) (cdr (cdr x))) @end example +@end deffn cxr library procedure: (caaar pair) cxr library procedure: (caadr pair) @@ -4929,13 +4868,14 @@ principles. For example, caddr could be defined by Arbitrary compositions up to four deep are provided. -procedure: (null? obj) +@deffn procedure null? obj Returns #t if obj is the empty list, otherwise returns #f. +@end deffn -procedure: (list? obj) +@deffn procedure list? obj Returns #t if @@ -4952,9 +4892,10 @@ terminated by the empty list. (list? x)) @result{} #f @end example +@end deffn -procedure: (make-list k) -procedure: (make-list k fill) +@deffn procedure make-list k +@deffnx procedure make-list k fill Returns a newly allocated list of @@ -4967,9 +4908,9 @@ fill. Otherwise the initial contents of each element is unspecified. (make-list 2 3) @result{} (3 3) @end example +@end deffn -procedure: (list obj @dots{}) - +@deffn procedure list obj @dots{} Returns a newly allocated list of its arguments. @@ -4979,8 +4920,9 @@ Returns a newly allocated list of its arguments. (list) @result{} () @end example +@end deffn -procedure: (length @var{list}) +@deffn procedure length list Returns the length of @var{list}. @@ -4991,8 +4933,9 @@ Returns the length of @var{list}. (length '()) @result{} 0 @end example +@end deffn -procedure: (append @var{list} @dots{}) +@deffn procedure append list@dots{} The last argument, if there is one, can be of any type. @@ -5013,8 +4956,9 @@ improper list results if the last argument is not a proper list. (append '() 'a) @result{} a @end example +@end deffn -procedure: (reverse @var{list}) +@deffn procedure reverse list Returns a newly allocated list consisting of the elements of @var{list} in reverse order. @@ -5026,9 +4970,9 @@ Returns a newly allocated list consisting of the elements of @result{} ((e (f)) d (b c) a) @end example +@end deffn -procedure: (list-tail list k) - +@deffn procedure list-tail list k It is an error if @@ -5051,9 +4995,9 @@ k elements. The list-tail procedure could be defined by (list-tail (cdr x) (- k 1))))) @end example +@end deffn -procedure: (list-ref list k) - +@deffn procedure list-ref list k The @@ -5082,7 +5026,7 @@ k).) @end example -procedure: (list-set! list k obj) +@deffn procedure list-set! list k obj It is an error if @@ -5109,11 +5053,12 @@ list. @result{} error ; constant list @end example +@end deffn -procedure: (memq obj list) -procedure: (memv obj list) -procedure: (member obj list) -procedure: (member obj list compare) +@deffn procedure memq obj list +@deffnx procedure memv obj list +@deffnx procedure member obj list +@deffnx procedure member obj list compare These procedures return the first sublist of @@ -5156,11 +5101,12 @@ compare, if given, and equal? otherwise. (memv 101 '(100 101 102)) @result{} (101 102) @end example +@end deffn -procedure: (assq obj alist) -procedure: (assv obj alist) -procedure: (assoc obj alist) -procedure: (assoc obj alist compare) +@deffn procedure assq obj alist +@deffnx procedure assv obj alist +@deffnx procedure assoc obj alist +@deffnx procedure assoc obj alist compare It is an error if @@ -5205,8 +5151,9 @@ compare if given and equal? otherwise. Rationale: Although they are often used as predicates, memq, memv, member, assq, assv, and assoc do not have question marks in their names because they return potentially useful values rather than just #t or #f. +@end deffn -procedure: (list-copy obj) +@deffn procedure list-copy obj Returns a newly allocated copy of the given @@ -5231,6 +5178,7 @@ b @result{} (3 8 2 8) a @result{} (1 8 2 8) @end example +@end deffn @node Symbols @section Symbols @@ -5251,7 +5199,7 @@ defeat write/read invariance, and also violate the rule that two symbols are the same if and only if their names are spelled the same. This report does not specify the behavior of implementation-dependent extensions. -procedure: (symbol? obj) +@deffn procedure symbol? obj Returns #t if @@ -5267,16 +5215,17 @@ obj is a symbol, otherwise returns #f. (symbol? #f) @result{} #f @end example +@end deffn -procedure: (symbol=? symbol1 symbol2 symbol3 @dots{}) - +@deffn procedure symbol=? symbol1 symbol2 symbol3 @dots{} Returns #t if all the arguments all have the same names in the sense of string=?. Note: The definition above assumes that none of the arguments are uninterned symbols. +@end deffn -procedure: (symbol->string symbol) +@deffn procedure symbol->string symbol Returns the name of @@ -5293,8 +5242,9 @@ procedures like string-set! to strings returned by this procedure. @result{} "Malvina" @end example +@end deffn -procedure: (string->symbol string) +@deffn procedure string->symbol string Returns the symbol whose name is @@ -5317,6 +5267,7 @@ would require escaping when written, but does not interpret escapes in its input @result{} #t @end example +@end deffn @node Characters @section Characters @@ -5390,48 +5341,32 @@ quoted in programs. Some of the procedures that operate on characters ignore the difference between upper case and lower case. The procedures that ignore case have ``-ci'' (for ``case insensitive'') embedded in their names. -procedure: (char? obj) +@deffn procedure char? obj Returns #t if obj is a character, otherwise returns #f. +@end deffn -procedure: (char=? char1 char2 char3 @dots{}) - - -procedure: (char<? char1 char2 char3 @dots{}) - - -procedure: (char>? char1 char2 char3 @dots{}) - - -procedure: (char<=? char1 char2 char3 @dots{}) - - -procedure: (char>=? char1 char2 char3 @dots{}) - +@deffn procedure char=? char1 char2 char3 @dots{} +@deffnx procedure char<? char1 char2 char3 @dots{} +@deffnx procedure char>? char1 char2 char3 @dots{} +@deffnx procedure char<=? char1 char2 char3 @dots{} +@deffnx procedure char>=? char1 char2 char3 @dots{} These procedures return #t if the results of passing their arguments to char->integer are respectively equal, monotonically increasing, monotonically decreasing, monotonically non-decreasing, or monotonically non-increasing. These predicates are required to be transitive. +@end deffn char library procedure: (char-ci=? char1 char2 char3 @dots{}) - - char library procedure: (char-ci<? char1 char2 char3 @dots{}) - - char library procedure: (char-ci>? char1 char2 char3 @dots{}) - - char library procedure: (char-ci<=? char1 char2 char3 @dots{}) - - char library procedure: (char-ci>=? char1 char2 char3 @dots{}) - These procedures are similar to char=? et cetera, but they treat upper case and lower case letters as the same. For example, (char-ci=? #\A #\a) returns #t. @@ -5465,9 +5400,8 @@ This procedure returns the numeric value (0 to 9) of its argument if it is a num @end example -procedure: (char->integer char) -procedure: (integer->char n) - +@deffn procedure char->integer char +@deffnx procedure integer->char n Given a Unicode character, char->integer returns an exact integer between 0 and #xD7FF or between #xE000 and #x10FFFF which is equal to the Unicode scalar value of that @@ -5477,6 +5411,7 @@ representation internally. Given an exact integer that is the value returned by a character when char->integer is applied to it, integer->char returns that character. +@end deffn char library procedure: (char-upcase char) char library procedure: (char-downcase char) @@ -5564,17 +5499,15 @@ utf8->string (see section 6.9). It is also an error for a procedure passed to st (see section 6.10) to return a forbidden character, or for read-string (see section 6.13.2) to attempt to read one. -procedure: (string? obj) +@deffn procedure string? obj Returns #t if obj is a string, otherwise returns #f. +@end deffn -procedure: (make-string k) - - -procedure: (make-string k char) - +@deffn procedure make-string k +@deffnx procedure make-string k char The make-string procedure returns a newly allocated string of length @@ -5583,18 +5516,21 @@ k. If char is given, then all the characters of the string are initialized to char, otherwise the contents of the string are unspecified. +@end deffn -procedure: (string char @dots{}) +@deffn procedure string char @dots{} Returns a newly allocated string composed of the arguments. It is analogous to list. +@end deffn -procedure: (string-length string) +@deffn procedure string-length string Returns the number of characters in the given string. +@end deffn -procedure: (string-ref string k) +@deffn procedure string-ref string k It is an error if @@ -5610,8 +5546,9 @@ k of string using zero-origin indexing. There is no requirement for this procedure to execute in constant time. +@end deffn -procedure: (string-set! string k char) +@deffn procedure string-set! string k char It is an error if @@ -5638,12 +5575,13 @@ string. There is no requirement for this procedure to execute in constant time. #\?) @result{} error @end example +@end deffn -procedure: (string=? string1 string2 string3 @dots{}) - +@deffn procedure string=? string1 string2 string3 @dots{} Returns #t if all the strings are the same length and contain exactly the same characters in the same positions, otherwise returns #f. +@end deffn char library procedure: (string-ci=? string1 string2 string3 @dots{}) @@ -5652,29 +5590,14 @@ Returns #t if, after case-folding, all the strings are the same length and conta characters in the same positions, otherwise returns #f. Specifically, these procedures behave as if string-foldcase were applied to their arguments before comparing them. -procedure: (string<? string1 string2 string3 @dots{}) - - -char library procedure: (string-ci<? string1 string2 string3 @dots{}) - - -procedure: (string>? string1 string2 string3 @dots{}) - - -char library procedure: (string-ci>? string1 string2 string3 @dots{}) - - -procedure: (string<=? string1 string2 string3 @dots{}) - - -char library procedure: (string-ci<=? string1 string2 string3 @dots{}) - - -procedure: (string>=? string1 string2 string3 @dots{}) - - -char library procedure: (string-ci>=? string1 string2 string3 @dots{}) - +@deffn procedure string<? string1 string2 string3@dots{} +@deffnx {char library procedure} string-ci<? string1 string2 string3@dots{} +@deffnx procedure string>? string1 string2 string3@dots{} +@deffnx {char library procedure} string-ci>? string1 string2 string3@dots{} +@deffnx procedure string<=? string1 string2 string3@dots{} +@deffnx {char library procedure} string-ci<=? string1 string2 string3@dots{} +@deffnx procedure string>=? string1 string2 string3@dots{} +@deffnx {char library procedure} string-ci>=? string1 string2 string3@dots{} These procedures return #t if their arguments are (respectively): monotonically increasing, monotonically decreasing, monotonically non-decreasing, or monotonically @@ -5697,6 +5620,7 @@ only if they do not satisfy string<?. The ``-ci'' procedures behave as if they applied string-foldcase to their arguments before invoking the corresponding procedures without ``-ci''. +@end deffn char library procedure: (string-upcase string) char library procedure: (string-downcase string) @@ -5712,7 +5636,7 @@ at the end of a word. See UAX #44 [11] (part of the Unicode Standard) for detail However, implementations of string-downcase are not required to provide this behavior, and may choose to change Σ to σ in all cases. -procedure: (substring string start end) +@deffn procedure substring string start end The substring procedure returns a newly allocated string formed from the characters of @@ -5722,17 +5646,18 @@ start and ending with index end. This is equivalent to calling string-copy with the same arguments, but is provided for backward compatibility and stylistic flexibility. +@end deffn -procedure: (string-append string @dots{}) - +@deffn procedure string-append string @dots{} Returns a newly allocated string whose characters are the concatenation of the characters in the given strings. +@end deffn -procedure: (string->list string) -procedure: (string->list string start) -procedure: (string->list string start end) -procedure: (list->string list) +@deffn procedure string->list string +@deffnx procedure string->list string start +@deffnx procedure string->list string start end +@deffnx procedure list->string list It is an error if any element of @@ -5748,10 +5673,11 @@ end. list->string returns a newly allocated string formed from the elements in t list. In both procedures, order is preserved. string->list and list->string are inverses so far as equal? is concerned. +@end deffn -procedure: (string-copy string) -procedure: (string-copy string start) -procedure: (string-copy string start end) +@deffn procedure string-copy string +@deffnx procedure string-copy string start +@deffnx procedure string-copy string start end Returns a newly allocated copy of the part of the given @@ -5760,10 +5686,11 @@ string between start and end. +@end deffn -procedure: (string-copy! to at from) -procedure: (string-copy! to at from start) -procedure: (string-copy! to at from start end) +@deffn procedure string-copy! to at from +@deffnx procedure string-copy! to at from start +@deffnx procedure string-copy! to at from start end It is an error if @@ -5802,10 +5729,11 @@ making sure to copy in the correct direction in such circumstances. b @result{} "a12de" @end example +@end deffn -procedure: (string-fill! string fill) -procedure: (string-fill! string fill start) -procedure: (string-fill! string fill start end) +@deffn procedure string-fill! string fill +@deffnx procedure string-fill! string fill start +@deffnx procedure string-fill! string fill start end It is an error if @@ -5820,6 +5748,7 @@ string between start and end. +@end deffn @node Vectors @section Vectors @@ -5842,22 +5771,24 @@ list (2 2 2 2) in element 1, and the string "Anna" in element 2 can be written a #(0 (2 2 2 2) "Anna") Vector constants are self-evaluating, so they do not need to be quoted in programs. -procedure: (vector? obj) +@deffn procedure vector? obj Returns #t if obj is a vector; otherwise returns #f. +@end deffn -procedure: (make-vector k) -procedure: (make-vector k fill) +@deffn procedure make-vector k +@deffnx procedure make-vector k fill Returns a newly allocated vector of k elements. If a second argument is given, then each element is initialized to fill. Otherwise the initial contents of each element is unspecified. +@end deffn -procedure: (vector obj @dots{}) +@deffn procedure vector obj @dots{} Returns a newly allocated vector whose elements contain the given arguments. It is analogous to list. @@ -5867,14 +5798,16 @@ analogous to list. (vector 'a 'b 'c) @result{} #(a b c) @end example +@end deffn -procedure: (vector-length vector) +@deffn procedure vector-length vector Returns the number of elements in vector as an exact integer. +@end deffn -procedure: (vector-ref vector k) +@deffn procedure vector-ref vector k It is an error if @@ -5899,8 +5832,9 @@ vector. @result{} 13 @end example +@end deffn -procedure: (vector-set! vector k obj) +@deffn procedure vector-set! vector k obj It is an error if @@ -5927,11 +5861,12 @@ vector. @result{} error ; constant vector @end example +@end deffn -procedure: (vector->list vector) -procedure: (vector->list vector start) -procedure: (vector->list vector start end) -procedure: (list->vector list) +@deffn procedure vector->list vector +@deffnx procedure vector->list vector start +@deffnx procedure vector->list vector start end +@deffnx procedure list->vector list The vector->list procedure returns a newly allocated list of the objects contained in the elements of @@ -5957,13 +5892,14 @@ In both procedures, order is preserved. @result{} #(dididit dah) @end example +@end deffn -procedure: (vector->string vector) -procedure: (vector->string vector start) -procedure: (vector->string vector start end) -procedure: (string->vector string) -procedure: (string->vector string start) -procedure: (string->vector string start end) +@deffn procedure vector->string vector +@deffnx procedure vector->string vector start +@deffnx procedure vector->string vector start end +@deffnx procedure string->vector string +@deffnx procedure string->vector string start +@deffnx procedure string->vector string start end It is an error if any element of @@ -5998,10 +5934,11 @@ In both procedures, order is preserved. #(#\1 #\2 #\3) @result{} "123" @end example +@end deffn -procedure: (vector-copy vector) -procedure: (vector-copy vector start) -procedure: (vector-copy vector start end) +@deffn procedure vector-copy vector +@deffnx procedure vector-copy vector start +@deffnx procedure vector-copy vector start end Returns a newly allocated copy of the elements of the given @@ -6022,10 +5959,11 @@ b @result{} #(3 8 2 8) c @result{} #(8 2) @end example +@end deffn -procedure: (vector-copy! to at from) -procedure: (vector-copy! to at from start) -procedure: (vector-copy! to at from start end) +@deffn procedure vector-copy! to at from +@deffnx procedure vector-copy! to at from start +@deffnx procedure vector-copy! to at from start end It is an error if @@ -6064,9 +6002,9 @@ making sure to copy in the correct direction in such circumstances. b @result{} #(10 1 2 40 50) @end example +@end deffn -procedure: (vector-append vector @dots{}) - +@deffn procedure vector-append vector@dots{} Returns a newly allocated vector whose elements are the concatenation of the elements of the given vectors. @@ -6077,10 +6015,11 @@ of the given vectors. @result{} #(a b c d e f) @end example +@end deffn -procedure: (vector-fill! vector fill) -procedure: (vector-fill! vector fill start) -procedure: (vector-fill! vector fill start end) +@deffn procedure vector-fill! vector fill +@deffnx procedure vector-fill! vector fill start +@deffnx procedure vector-fill! vector fill start end The vector-fill! procedure stores @@ -6100,6 +6039,7 @@ a @result{} #(1 2 smash smash 5) @end example +@end deffn @node Bytevectors @section Bytevectors @@ -6121,14 +6061,14 @@ byte @dots{}). For example, a bytevector of length 3 containing the byte 0 in el #u8(0 10 5) Bytevector constants are self-evaluating, so they do not need to be quoted in programs. -procedure: (bytevector? obj) +@deffn procedure bytevector? obj Returns #t if obj is a bytevector. Otherwise, #f is returned. -procedure: (make-bytevector k) -procedure: (make-bytevector k byte) +@deffn procedure make-bytevector k +@deffnx procedure make-bytevector k byte The make-bytevector procedure returns a newly allocated bytevector of length @@ -6143,9 +6083,9 @@ byte, otherwise the contents of each element are unspecified. (make-bytevector 2 12) @result{} #u8(12 12) @end example +@end deffn -procedure: (bytevector byte @dots{}) - +@deffn procedure bytevector byte@dots{} Returns a newly allocated bytevector containing its arguments. @@ -6155,14 +6095,16 @@ Returns a newly allocated bytevector containing its arguments. (bytevector) @result{} #u8() @end example +@end deffn -procedure: (bytevector-length bytevector) +@deffn procedure bytevector-length bytevector Returns the length of bytevector in bytes as an exact integer. +@end deffn -procedure: (bytevector-u8-ref bytevector k) +@deffn procedure bytevector-u8-ref bytevector k It is an error if @@ -6183,8 +6125,9 @@ bytevector. @result{} 8 @end example +@end deffn -procedure: (bytevector-u8-set! bytevector k byte) +@deffn procedure bytevector-u8-set! bytevector k byte It is an error if @@ -6208,10 +6151,11 @@ bytevector. @result{} #u8(1 3 3 4) @end example +@end deffn -procedure: (bytevector-copy bytevector) -procedure: (bytevector-copy bytevector start) -procedure: (bytevector-copy bytevector start end) +@deffn procedure bytevector-copy bytevector +@deffnx procedure bytevector-copy bytevector start +@deffnx procedure bytevector-copy bytevector start end Returns a newly allocated bytevector containing the bytes in @@ -6228,9 +6172,9 @@ end. @end example -procedure: (bytevector-copy! to at from) -procedure: (bytevector-copy! to at from start) -procedure: (bytevector-copy! to at from start end) +@deffn procedure bytevector-copy! to at from +@deffnx procedure bytevector-copy! to at from start +@deffnx procedure bytevector-copy! to at from start end It is an error if @@ -6272,9 +6216,9 @@ b @result{} #u8(10 1 2 40 50) Note: This procedure appears in R6RS, but places the source before the destination, contrary to other such procedures in Scheme. +@end deffn -procedure: (bytevector-append bytevector @dots{}) - +@deffn procedure bytevector-append bytevector@dots{} Returns a newly allocated bytevector whose elements are the concatenation of the elements in the given bytevectors. @@ -6285,13 +6229,14 @@ elements in the given bytevectors. @result{} #u8(0 1 2 3 4 5) @end example +@end deffn -procedure: (utf8->string bytevector) -procedure: (utf8->string bytevector start) -procedure: (utf8->string bytevector start end) -procedure: (string->utf8 string) -procedure: (string->utf8 string start) -procedure: (string->utf8 string start end) +@deffn procedure utf8->string bytevector +@deffnx procedure utf8->string bytevector start +@deffnx procedure utf8->string bytevector start end +@deffnx procedure string->utf8 string +@deffnx procedure string->utf8 string start +@deffnx procedure string->utf8 string start end It is an error for @@ -6316,6 +6261,7 @@ end and returns the corresponding bytevector. (string->utf8 "λ") @result{} #u8(#xCE #xBB) @end example +@end deffn @node Control features @section Control features @@ -6325,7 +6271,7 @@ execution in special ways. Procedures in this section that invoke procedure argu always do so in the same dynamic environment as the call of the original procedure. The procedure? predicate is also described here. -procedure: (procedure? obj) +@deffn procedure procedure? obj Returns #t if @@ -6343,9 +6289,9 @@ obj is a procedure, otherwise returns #f. @result{} #t @end example +@end deffn -procedure: (apply proc arg1 @dots{} args) - +@deffn procedure apply proc arg1@dots{} args The apply procedure calls @@ -6363,9 +6309,9 @@ proc with the elements of the list @code{(append (list arg1 @dots{}) args)} as t ((compose sqrt *) 12 75) @result{} 30 @end example +@end deffn -procedure: (map proc list1 list2 @dots{}) - +@deffn procedure map proc list1 list2@dots{} It is an error if @@ -6409,9 +6355,9 @@ returns are not mutated. or (2 1) @end example +@end deffn -procedure: (string-map proc string1 string2 @dots{}) - +@deffn procedure string-map proc string1 string2@dots{} It is an error if @@ -6452,9 +6398,9 @@ earlier returns are not mutated. @result{} "StUdLyCaPs" @end example +@end deffn -procedure: (vector-map proc vector1 vector2 @dots{}) - +@deffn procedure vector-map proc vector1 vector2@dots{} It is an error if @@ -6496,9 +6442,9 @@ earlier returns are not mutated. or #(2 1) @end example +@end deffn -procedure: (for-each proc list1 list2 @dots{}) - +@deffn procedure for-each proc list1 list2@dots{} It is an error if @@ -6532,9 +6478,9 @@ proc to mutate any of the lists. v) @result{} #(0 1 4 9 16) @end example +@end deffn -procedure: (string-for-each proc string1 string2 @dots{}) - +@deffn procedure string-for-each proc string1 string2@dots{} It is an error if @@ -6565,9 +6511,9 @@ proc to mutate any of the strings. v) @result{} (101 100 99 98 97) @end example +@end deffn -procedure: (vector-for-each proc vector1 vector2 @dots{}) - +@deffn procedure vector-for-each proc vector1 vector2@dots{} It is an error if @@ -6598,9 +6544,10 @@ proc to mutate any of the vectors. v) @result{} (0 1 4 9 16) @end example +@end deffn -procedure: (call-with-current-continuation proc) -procedure: (call/cc proc) +@deffn procedure call-with-current-continuation proc +@deffnx procedure call/cc proc It is an error if @@ -6687,8 +6634,9 @@ Rationale: A common use of call-with-current-continuation is for structured, occasions, however, a programmer needs to deal with continuations explicitly. The call-with-current-continuation procedure allows Scheme programmers to do that by creating a procedure that acts just like the current continuation. +@end deffn -procedure: (values obj @dots{}) +@deffn procedure values obj @dots{} Delivers all of its arguments to its continuation. The values procedure might be defined as follows: @@ -6700,8 +6648,9 @@ as follows: (lambda (cont) (apply cont things)))) @end example +@end deffn -procedure: (call-with-values producer consumer) +@deffn procedure call-with-values producer consumer Calls its @@ -6721,8 +6670,9 @@ consumer is the continuation of the call to call-with-values. (call-with-values * -) @result{} -1 @end example +@end deffn -procedure: (dynamic-wind before thunk after) +@deffn procedure dynamic-wind before thunk after Calls @@ -6812,6 +6762,7 @@ after is unspecified. connect talk2 disconnect) @end example +@end deffn @node Exceptions @section Exceptions @@ -6829,8 +6780,7 @@ object encapsulating information about the exception. Any procedure accepting on argument can serve as an exception handler and any object can be used to represent an exception. -procedure: (with-exception-handler handler thunk) - +@deffn procedure with-exception-handler handler thunk It is an error if @@ -6871,9 +6821,9 @@ thunk. exception. @end example +@end deffn -procedure: (raise obj) - +@deffn procedure raise obj Raises an exception by invoking the current exception handler on @@ -6883,9 +6833,9 @@ being called was installed. If the handler returns, a secondary exception is rai same dynamic environment as the handler. The relationship between obj and the object raised by the secondary exception is unspecified. +@end deffn -procedure: (raise-continuable obj) - +@deffn procedure raise-continuable obj Raises an exception by invoking the current exception handler on @@ -6912,9 +6862,9 @@ the values it returns become the values returned by the call to raise-continuabl @result{} 65 @end example +@end deffn -procedure: (error message obj @dots{}) - +@deffn procedure error message obj @dots{} Message should be a string. @@ -6936,34 +6886,39 @@ objs, known as the irritants. The procedure error-object? must return #t on such l)))) @end example +@end deffn -procedure: (error-object? obj) +@deffn procedure error-object? obj Returns #t if obj is an object created by error or one of an implementation-defined set of objects. Otherwise, it returns #f. The objects used to signal errors, including those which satisfy the predicates file-error? and read-error?, may or may not satisfy error-object?. +@end deffn -procedure: (error-object-message error-object) +@deffn procedure error-object-message error-object Returns the message encapsulated by error-object. +@end deffn -procedure: (error-object-irritants error-object) +@deffn procedure error-object-irritants error-object Returns a list of the irritants encapsulated by error-object. +@end deffn -procedure: (read-error? obj) -procedure: (file-error? obj) +@deffn procedure read-error? obj +@deffnx procedure file-error? obj Error type predicates. Returns #t if obj is an object raised by the read procedure or by the inability to open an input or output port on a file, respectively. Otherwise, it returns #f. +@end deffn @node Environments and evaluation @section Environments and evaluation @@ -7085,7 +7040,7 @@ implementation-dependent. Ports can be used to access files, devices, and similar things on the host system on which the Scheme program is running. -procedure: (call-with-port port proc) +@deffn procedure call-with-port port proc It is an error if @@ -7122,28 +7077,28 @@ output as if by open-input-file or open-output-file. The port and proc are then passed to a procedure equivalent to call-with-port. -procedure: (input-port? obj) -procedure: (output-port? obj) -procedure: (textual-port? obj) -procedure: (binary-port? obj) -procedure: (port? obj) +@deffn procedure input-port? obj +@deffn procedure output-port? obj +@deffn procedure textual-port? obj +@deffn procedure binary-port? obj +@deffn procedure port? obj These procedures return #t if obj is an input port, output port, textual port, binary port, or any kind of port, respectively. Otherwise they return #f. -procedure: (input-port-open? port) -procedure: (output-port-open? port) +@deffn procedure input-port-open? port +@deffn procedure output-port-open? port Returns #t if port is still open and capable of performing input or output, respectively, and #f otherwise. -procedure: (current-input-port) -procedure: (current-output-port) -procedure: (current-error-port) +@deffn procedure current-input-port +@deffn procedure current-output-port +@deffn procedure current-error-port Returns the current default input port, output port, or error port (an output port), respectively. These procedures are parameter objects, which can be overridden with @@ -7188,9 +7143,9 @@ output port that is capable of writing data to a new file by that name. If a fil given name already exists, the effect is unspecified. If the file cannot be opened, an error that satisfies file-error? is signaled. -procedure: (close-port port) -procedure: (close-input-port port) -procedure: (close-output-port port) +@deffn procedure close-port port +@deffn procedure close-input-port port +@deffn procedure close-output-port port Closes the resource associated with @@ -7204,17 +7159,17 @@ to close the input and output sides of the port independently. These routines have no effect if the port has already been closed. -procedure: (open-input-string string) +@deffn procedure open-input-string string Takes a string and returns a textual input port that delivers characters from the string. If the string is modified, the effect is unspecified. -procedure: (open-output-string) +@deffn procedure open-output-string Returns a textual output port that will accumulate characters for retrieval by get-output-string. -procedure: (get-output-string port) +@deffn procedure get-output-string port It is an error if @@ -7238,17 +7193,17 @@ the order they were output. If the result string is modified, the effect is unsp @end example -procedure: (open-input-bytevector bytevector) +@deffn procedure open-input-bytevector bytevector Takes a bytevector and returns a binary input port that delivers bytes from the bytevector. -procedure: (open-output-bytevector) +@deffn procedure open-output-bytevector Returns a binary output port that will accumulate bytes for retrieval by get-output-bytevector. -procedure: (get-output-bytevector port) +@deffn procedure get-output-bytevector port It is an error if @@ -7287,8 +7242,8 @@ encountered after the beginning of an object's external representation, but the representation is incomplete and therefore not parsable, an error that satisfies read-error? is signaled. -procedure: (read-char) -procedure: (read-char port) +@deffn procedure read-char +@deffn procedure read-char port Returns the next character available from the textual input @@ -7297,8 +7252,8 @@ port, updating the port to point to the following character. If no more characters are available, an end-of-file object is returned. -procedure: (peek-char) -procedure: (peek-char port) +@deffn procedure peek-char +@deffn procedure peek-char port Returns the next character available from the textual input @@ -7316,8 +7271,8 @@ port will return the value returned by the preceding call to peek-char. In parti call to peek-char on an interactive port will hang waiting for input whenever a call to read-char would have hung. -procedure: (read-line) -procedure: (read-line port) +@deffn procedure read-line +@deffn procedure read-line port Returns the next line of text available from the textual input @@ -7333,7 +7288,7 @@ linefeed character, a carriage return character, or a sequence of a carriage ret character followed by a linefeed character. Implementations may also recognize other end of line characters or sequences. -procedure: (eof-object? obj) +@deffn procedure eof-object? obj Returns #t if @@ -7341,12 +7296,12 @@ obj is an end-of-file object, otherwise returns #f. The precise set of end-of-fi will vary among implementations, but in any case no end-of-file object will ever be an object that can be read in using read. -procedure: (eof-object) +@deffn procedure eof-object Returns an end-of-file object, not necessarily unique. -procedure: (char-ready?) -procedure: (char-ready? port) +@deffn procedure char-ready? +@deffn procedure char-ready? port Returns #t if a character is ready on the textual input @@ -7364,8 +7319,8 @@ existence has been asserted by char-ready? cannot be removed from the input. If char-ready? were to return #f at end of file, a port at end of file would be indistinguishable from an interactive port that has no ready characters. -procedure: (read-string k) -procedure: (read-string k port) +@deffn procedure read-string k +@deffn procedure read-string k port Reads the next @@ -7374,8 +7329,8 @@ k characters, or as many as are available before the end of file, from the textu port into a newly allocated string in left-to-right order and returns the string. If no characters are available before the end of file, an end-of-file object is returned. -procedure: (read-u8) -procedure: (read-u8 port) +@deffn procedure read-u8 +@deffn procedure read-u8 port Returns the next byte available from the binary input @@ -7384,8 +7339,8 @@ port, updating the port to point to the following byte. If no more bytes are available, an end-of-file object is returned. -procedure: (peek-u8) -procedure: (peek-u8 port) +@deffn procedure peek-u8 +@deffn procedure peek-u8 port Returns the next byte available from the binary input @@ -7394,8 +7349,8 @@ port, but without updating the port to point to the following byte. If no more bytes are available, an end-of-file object is returned. -procedure: (u8-ready?) -procedure: (u8-ready? port) +@deffn procedure u8-ready? +@deffn procedure u8-ready? port Returns #t if a byte is ready on the binary input @@ -7406,8 +7361,8 @@ port is guaranteed not to hang. If the port is at end of file then u8-ready? returns #t. -procedure: (read-bytevector k) -procedure: (read-bytevector k port) +@deffn procedure read-bytevector k +@deffn procedure read-bytevector k port Reads the next @@ -7416,10 +7371,10 @@ k bytes, or as many as are available before the end of file, from the binary inp port into a newly allocated bytevector in left-to-right order and returns the bytevector. If no bytes are available before the end of file, an end-of-file object is returned. -procedure: (read-bytevector! bytevector) -procedure: (read-bytevector! bytevector port) -procedure: (read-bytevector! bytevector port start) -procedure: (read-bytevector! bytevector port start end) +@deffn procedure read-bytevector! bytevector +@deffn procedure read-bytevector! bytevector port +@deffn procedure read-bytevector! bytevector port start +@deffn procedure read-bytevector! bytevector port start end Reads the next end − start bytes, or as many as are available before the end of file, from the binary input @@ -7507,16 +7462,16 @@ The display procedure returns an unspecified value. Rationale: The write procedure is intended for producing machine-readable output and display for producing human-readable output. -procedure: (newline) -procedure: (newline port) +@deffn procedure newline +@deffn procedure newline port Writes an end of line to textual output port. Exactly how this is done differs from one operating system to another. Returns an unspecified value. -procedure: (write-char char) -procedure: (write-char char port) +@deffn procedure write-char char +@deffn procedure write-char char port Writes the character @@ -7524,10 +7479,10 @@ char (not an external representation of the character) to the given textual outp port and returns an unspecified value. -procedure: (write-string string) -procedure: (write-string string port) -procedure: (write-string string port start) -procedure: (write-string string port start end) +@deffn procedure write-string string +@deffn procedure write-string string port +@deffn procedure write-string string port start +@deffn procedure write-string string port start end Writes the characters of @@ -7539,8 +7494,8 @@ end in left-to-right order to the textual output port. -procedure: (write-u8 byte) -procedure: (write-u8 byte port) +@deffn procedure write-u8 byte +@deffn procedure write-u8 byte port Writes the @@ -7548,10 +7503,10 @@ byte to the given binary output port and returns an unspecified value. -procedure: (write-bytevector bytevector) -procedure: (write-bytevector bytevector port) -procedure: (write-bytevector bytevector port start) -procedure: (write-bytevector bytevector port start end) +@deffn procedure write-bytevector bytevector +@deffn procedure write-bytevector bytevector port +@deffn procedure write-bytevector bytevector port start +@deffn procedure write-bytevector bytevector port start end Writes the bytes of @@ -7563,8 +7518,8 @@ end in left-to-right order to the binary output port. -procedure: (flush-output-port) -procedure: (flush-output-port port) +@deffn procedure flush-output-port +@deffn procedure flush-output-port port Flushes any buffered output from the buffer of output-port to the underlying file or device and returns an unspecified value. @@ -7733,7 +7688,7 @@ an implementation-specified constant. @end example -procedure: (features) +@deffn procedure features Returns a list of the feature identifiers which cond-expand treats as true. It is an error to modify this list. Here is an example of what features might return: