Scheme Index (Static)

Hello! This is a project borne from the frustration of using index.scheme.org: the site is extremely slow due to being written in Angular. This site here is an attempt to reproduce (most of) the functionality of index.scheme org. But with static pre-rendered pages and zero JavaScript required. (index.scheme.org requires JavaScript to work, locking the users of older / weaker / JS-less browsers out.) Some of the features present on index.scheme.org are not present here. For reasons:

Other than that, it’s quite similar: choose the libraries you need, and search / skim / read their docs.

This site is sourced from scheme-index repository.

library (rnrs base (6))

(rnrs base (6)) procedure (* (z number?) ... ) ⟹ number?

This procedure returns the product of its arguments.

(rnrs base (6)) procedure (+ (z number?) ... ) ⟹ number?

This procedure returns the sum of its arguments.

(rnrs base (6)) procedure (- (z number?) ... ) ⟹ number?

With two or more arguments, this procedures returns the difference of its arguments, associating to the left. With one argument, however, it returns the additive inverse of its argument.

(rnrs base (6)) procedure (/ (z1 number?) (z2 number?) ... ) ⟹ number?

If all of the arguments are exact, then the divisors must all be nonzero. With two or more arguments, this procedure returns the quotient of its arguments, associating to the left. With one argument, however, it returns the multiplicative inverse of its argument.

(rnrs base (6)) procedure (< (x1 real?) (x2 real?) (x3 real?) ... ) ⟹ boolean?

This procedure returns #t if its arguments are monotonically increasing, and #f otherwise.

(rnrs base (6)) procedure (<= (x1 real?) (x2 real?) (x3 real?) ... ) ⟹ boolean?

This procedure returns #t if its arguments are monotonically nondecreasing, and #f otherwise.

(rnrs base (6)) procedure (= (z1 number?) (z2 number?) (z3 number?) ... ) ⟹ boolean?

This procedure returns #t if its arguments are equal, and #f otherwise.

(rnrs base (6)) procedure (> (x1 real?) (x2 real?) (x3 real?) ... ) ⟹ boolean?

This procedure returns #t if its arguments are decreasing, and #f otherwise.

(rnrs base (6)) procedure (>= (x1 real?) (x2 real?) (x3 real?) ... ) ⟹ boolean?

This procedure returns #t if its arguments are monotonically nonincreasing, and #f otherwise.

(rnrs base (6)) procedure (abs (x real?) ) ⟹ number?

Returns the absolute value of its argument.

(rnrs base (6)) syntax (and () ((_ test1 ...)) )

Semantics: If there are no <test>s, #t is returned. Otherwise, the <test> expressions are evaluated from left to right until a <test> returns #f or the last <test> is reached. In the former case, the and expression returns #f without evaluating the remaining expressions. In the latter case, the last expression is evaluated and its values are returned.

(rnrs base (6)) procedure (append (list list?) ... ) ⟹ list?

(rnrs base (6)) procedure (append (list list?) ... obj ) ⟹ *

Returns a possibly improper list consisting of the elements of the first list followed by the elements of the other lists, with obj as the cdr of the final pair. An improper list results if obj is not a list.

If append constructs a nonempty chain of pairs, it is always newly allocated. If no pairs are allocated, obj is returned.

(rnrs base (6)) procedure (apply (proc procedure?) arg1 ... (rest-args list?) ) ⟹ *

Rest-args must be a list. Proc should accept n arguments, where n is number of args plus the length of rest-args. The apply procedure calls proc with the elements of the list (append (list arg1 ...) rest-args) as the actual arguments.

If a call to apply occurs in a tail context, the call to proc is also in a tail context.

(rnrs base (6)) procedure (assertion-violation (who (or string?symbol?#f)) (message string?) irritant1 ... ) ⟹ undefined

The assertion-violation procedure should be called when an invalid call to a procedure was made, either passing an invalid number of arguments, or passing an argument that it is not specified to handle.

The who argument should describe the procedure or operation that detected the exception. The message argument should describe the exceptional situation. The irritants should be the arguments to the operation that detected the operation.

The condition object provided with the exception (see library chapter on “Exceptions and conditions”) has the following condition types:

  • If who is not #f, the condition has condition type &who, with who as the value of its field. In that case, who should be the name of the procedure or entity that detected the exception. If it is #f, the condition does not have condition type &who.
  • The condition has condition type &message, with message as the value of its field.
  • The condition has condition type &irritants, and its field has as its value a list of the irritants.
  • Moreover, the condition created by assertion-violation has condition type &assertion.

    (rnrs base (6)) syntax (assert () ((_ expression)) )

    An assert form is evaluated by evaluating <expression>. If <expression> returns a true value, that value is returned from the assert expression. If <expression> returns #f, an exception with condition types &assertion and &message is raised. The message provided in the condition object is implementation-dependent.

    (rnrs base (6)) syntax (begin () ((_ expression-or-definition ...)) )

    The <begin> keyword has two different roles, depending on its context:

  • It may appear as a form in a <body> (see section 11.3), <library body> (see section 7.1), or <top-level body> (see chapter 8), or directly nested in a begin form that appears in a body. In this case, the begin form must have the shape specified in the first header line. This use of begin acts as a splicing form—the forms inside the <body> are spliced into the surrounding body, as if the begin wrapper were not actually present.
  • A begin form in a <body> or <library body> must be non-empty if it appears after the first <expression> within the body.

  • It may appear as an ordinary expression and must have the shape specified in the second header line. In this case, the <expression>s are evaluated sequentially from left to right, and the values of the last <expression> are returned. This expression type is used to sequence side effects such as assignments or input and output.
  • (rnrs base (6)) procedure (boolean=? (boolean1 boolean?) (boolean2 boolean?) (boolean3 boolean?) ... ) ⟹ boolean?

    Returns #t if the booleans are the same.

    (rnrs base (6)) procedure (boolean? obj ) ⟹ boolean?

    Returns #t if obj is either #t or #f and returns #f otherwise.

    (rnrs base (6)) procedure (caar (pair pair?) ) ⟹ *

    Composition of car and car.

    (rnrs base (6)) procedure (cadr (pair pair?) ) ⟹ *

    Composition of car and cdr.

    (rnrs base (6)) procedure (call-with-current-continuation (proc procedure?) ) ⟹ *

    (proc (k procedure?) ) ⟹ *

    Proc should accept one argument. The procedure call-with-current-continuation (which is the same as the procedure call/cc) packages the current continuation as an "escape procedure" and passes it as an argument to proc. The escape procedure is a Scheme procedure that, if it is later called, will abandon whatever continuation is in effect at that later time and will instead reinstate the continuation that was in effect when the escape procedure was created. Calling the escape procedure may cause the invocation of before and after procedures installed using dynamic-wind.

    The escape procedure accepts the same number of arguments as the continuation of the original call to call-with-current-continuation.

    The escape procedure that is passed to proc has unlimited extent just like any other procedure in Scheme. It may be stored in variables or data structures and may be called as many times as desired.

    If a call to call-with-current-continuation occurs in a tail context, the call to proc is also in a tail context.

    Note: Calling an escape procedure reenters the dynamic extent of the call to call-with-current-continuation, and thus restores its dynamic environment; see section 5.12.

    (rnrs base (6)) procedure (call-with-values (producer procedure?) (consumer procedure?) ) ⟹ *

    (producer ) ⟹ *

    (consumer obj ... ) ⟹ *

    The call-with-values procedure calls producer with no arguments and a continuation that, when passed some values, calls the consumer procedure with those values as arguments. The continuation for the call to consumer is the continuation of the call to call-with-values. If a call to call-with-values occurs in a tail context, the call to consumer is also in a tail context.

    Implementation responsibilities: After producer returns, the implementation must check that consumer accepts as many values as consumer has returned.

    (rnrs base (6)) procedure (call/cc (proc procedure?) ) ⟹ *

    (proc (k procedure?) ) ⟹ *

    Proc should accept one argument. The procedure call-with-current-continuation (which is the same as the procedure call/cc) packages the current continuation as an "escape procedure" and passes it as an argument to proc. The escape procedure is a Scheme procedure that, if it is later called, will abandon whatever continuation is in effect at that later time and will instead reinstate the continuation that was in effect when the escape procedure was created. Calling the escape procedure may cause the invocation of before and after procedures installed using dynamic-wind.

    The escape procedure accepts the same number of arguments as the continuation of the original call to call-with-current-continuation.

    The escape procedure that is passed to proc has unlimited extent just like any other procedure in Scheme. It may be stored in variables or data structures and may be called as many times as desired.

    If a call to call-with-current-continuation occurs in a tail context, the call to proc is also in a tail context.

    Note: Calling an escape procedure reenters the dynamic extent of the call to call-with-current-continuation, and thus restores its dynamic environment; see section 5.12.

    (rnrs base (6)) procedure (car (pair pair?) ) ⟹ *

    Returns the contents of the car field of pair.

    (rnrs base (6)) syntax (case (=> else ) ((_ key clause1 clause2 ...)) )

    ((datum1 ...) expression1 expression2 ...) ((datum1 ...) => expression) (else expression1 expression2 ...)

    The second form, which specifies an "else clause", may only appear as the last <case clause>. Each <datum> is an external representation of some object. The data represented by the <datum>s need not be distinct.

    Semantics: A case expression is evaluated as follows. <Key> is evaluated and its result is compared using eqv? (see section 11.5) against the data represented by the <datum>s of each <case clause> in turn, proceeding in order from left to right through the set of clauses. If the result of evaluating <key> is equivalent to a datum of a <case clause>, the corresponding <expression>s are evaluated from left to right and the results of the last expression in the <case clause> are returned as the results of the case expression. Otherwise, the comparison process continues. If the result of evaluating <key> is different from every datum in each set, then if there is an else clause its expressions are evaluated and the results of the last are the results of the case expression; otherwise the case expression returns unspecified values.

    (rnrs base (6)) procedure (cdar (pair pair?) ) ⟹ *

    Composition of cdr and car.

    (rnrs base (6)) procedure (cddr (pair pair?) ) ⟹ *

    Composition of cdr and cdr.

    (rnrs base (6)) procedure (cdr (pair pair?) ) ⟹ *

    Returns the contents of the cdr field of pair.

    (rnrs base (6)) procedure (ceiling (x real?) ) ⟹ real?

    The ceiling procedure returns the smallest integer object not smaller than x.

    Note:‌ If the argument to the procedure is inexact, then the result is also inexact. If an exact value is needed, the result should be passed to the exact procedure.

    (rnrs base (6)) procedure (char->integer (char char?) ) ⟹ integer?

    Given a character, char->integer returns its Unicode scalar value as an exact integer object.

    (rnrs base (6)) procedure (char<=? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

    This procedure returns #t if the results of passing their arguments to char->integer are monotonically non-decreasing. This predicate is required to be transitive.

    (rnrs base (6)) procedure (char<? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

    This procedure returns #t if the results of passing their arguments to char->integer are monotonically increasing. This predicate is required to be transitive.

    (rnrs base (6)) procedure (char=? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

    This procedure returns #t if the results of passing their arguments to char->integer are equal. This predicate is required to be transitive.

    (rnrs base (6)) procedure (char>=? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

    This procedure returns #t if the results of passing their arguments to char->integer are monotonically non-increasing. This predicate is required to be transitive.

    (rnrs base (6)) procedure (char>? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

    This procedure returns #t if the results of passing their arguments to char->integer are monotonically decreasing. This predicate is required to be transitive.

    (rnrs base (6)) procedure (char? obj ) ⟹ boolean?

    Returns #t if obj is a character, otherwise returns #f.

    (rnrs base (6)) syntax (cond (else => ) ((_ clause1 clause2 ...)) )

    (test expression1 ...) (test => receiver) (else expression1 expression2 ...)

    receiver ⟹ procedure?

    A cond expression is evaluated by evaluating the <test> expressions of successive <cond clause>s in order until one of them evaluates to a true value(see section 5.7). When a <test> evaluates to a true value, then the remaining <expression>s in its <cond clause> are evaluated in order, and the results of the last <expression> in the <cond clause> are returned as the results of the entire cond expression. If the selected <cond clause> contains only the <test> and no <expression>s, then the value of the <test> is returned as the result. If the selected <cond clause> uses the => alternate form, then the <expression> is evaluated. Its value must be a procedure. This procedure should accept one argument; it is called on the value of the <test> and the values returned by this procedure are returned by the cond expression. If all <test>s evaluate to #f, and there is no else clause, then the conditional expression returns unspecified values; if there is an else clause, then its <expression>s are evaluated, and the values of the last one are returned.

    (rnrs base (6)) procedure (cons obj1 obj2 ) ⟹ pair?

    Returns a newly allocated pair whose car is obj1 and whose cdr is obj2. The pair is guaranteed to be different (in the sense of eqv?) from every existing object.

    (rnrs base (6)) syntax (define () ((_ variable expression)) ((_ variable)) ((_ (variable parameter1 ...) body)) ((_ (variable parameter1 ... . parameter) body)) )

    The define form described in this section is a <definition>used to create variable bindings and may appear anywhere other definitions may appear.

    The first from of define binds <variable> to a new location before assigning the value of <expression> to it. The continuation of <expression> should not be invoked more than once. Implementation responsibilities: Implementations should detect that the continuation of <expression> is invoked more than once. If the implementation detects this, it must raise an exception with condition type &assertion.

    The second form of define is equivalent to (define <variable> <unspecified>) where <unspecified> is a side-effect-free expression returning an unspecified value.

    In the third form of define, <formals> must be either a sequence of zero or more variables, or a sequence of one or more variables followed by a dot . and another variable (as in a lambda expression, see section 11.4.2). This form is equivalent to (define <variable>   (lambda (<formals>) <body>)).

    In the fourth form of define, <formal> must be a single variable. This form is equivalent to (define <variable> (lambda <formal> <body>)).

    (rnrs base (6)) syntax (define-syntax () ((_ keyword transformer-spec)) )

    transformer-spec ⟹ transformer-spec

    Binds <keyword> to the value of <expression>, which must evaluate, at macro-expansion time, to a transformer. Macro transformers can be created using the syntax-rules and identifier-syntax forms described in section 11.19. See library section on “Transformers” for a more complete description of transformers. Keyword bindings established by define-syntax are visible throughout the body in which they appear, except where shadowed by other bindings, and nowhere else, just like variable bindings established by define. All bindings established by a set of definitions, whether keyword or variable definitions, are visible within the definitions themselves.

    Implementation responsibilities: The implementation should detect if the value of <expression> cannot possibly be a transformer.

    (rnrs base (6)) procedure (div (x1 real?) (x2 real?) ) ⟹ integer?

    Number-theoretic integer division and return the results of the corresponding mathematical operations specified in section 11.7.3.1. x1 must be neither infinite nor a NaN, and x2 must be nonzero; otherwise, an exception with condition type &assertion is raised.

    (rnrs base (6)) procedure (div0 (x1 real?) (x2 real?) ) ⟹ integer?

    Number-theoretic integer division and return the results of the corresponding mathematical operations specified in section 11.7.3.1. x1 must be neither infinite nor a NaN, and x2 must be nonzero; otherwise, an exception with condition type &assertion is raised.

    (rnrs base (6)) procedure (div-and-mod (x1 real?) (x2 real?) ) ⟹ (values integer?real?)

    Number-theoretic integer division and return the results of the corresponding mathematical operations specified in section 11.7.3.1. x1 must be neither infinite nor a NaN, and x2 must be nonzero; otherwise, an exception with condition type &assertion is raised.

    (rnrs base (6)) procedure (div0-and-mod0 (x1 real?) (x2 real?) ) ⟹ (values integer?real?)

    Number-theoretic integer division and return the results of the corresponding mathematical operations specified in section 11.7.3.1. x1 must be neither infinite nor a NaN, and x2 must be nonzero; otherwise, an exception with condition type &assertion is raised.

    (rnrs base (6)) procedure (dynamic-wind (before procedure?) (thunk procedure?) (after procedure?) ) ⟹ *

    (before ) ⟹ undefined

    (thunk ) ⟹ *

    (after ) ⟹ undefined

    Before, thunk, and after must be procedures, and each should accept zero arguments. These procedures may return any number of values. The dynamic-wind procedure calls thunk without arguments, returning the results of this call. Moreover, dynamic-wind calls before without arguments whenever the dynamic extent of the call to thunk is entered, and after without arguments whenever the dynamic extent of the call to thunk is exited. Thus, in the absence of calls to escape procedures created by call-with-current-continuation, dynamic-wind calls before, thunk, and after, in that order.

    While the calls to before and after are not considered to be within the dynamic extent of the call to thunk, calls to the before and after procedures of any other calls to dynamic-wind that occur within the dynamic extent of the call to thunk are considered to be within the dynamic extent of the call to thunk.

    More precisely, an escape procedure transfers control out of the dynamic extent of a set of zero or more active dynamic-wind calls x ... and transfer control into the dynamic extent of a set of zero or more active dynamic-wind calls y .... It leaves the dynamic extent of the most recent x and calls without arguments the corresponding after procedure. If the after procedure returns, the escape procedure proceeds to the next most recent x, and so on. Once each x has been handled in this manner, the escape procedure calls without arguments the before procedure corresponding to the least recent y. If the before procedure returns, the escape procedure reenters the dynamic extent of the least recent y and proceeds with the next least recent y, and so on. Once each y has been handled in this manner, control is transferred to the continuation packaged in the escape procedure.

    Implementation responsibilities: The implementation must check the restrictions on thunk and after only if they are actually called.

    (rnrs base (6)) procedure (eq? obj1 obj2 ) ⟹ boolean?

    The eq? predicate is similar to eqv? except that in some cases it is capable of discerning distinctions finer than those detectable by eqv?.

    The eq? and eqv? predicates are guaranteed to have the same behavior on symbols, booleans, the empty list, pairs, procedures, non-empty strings, bytevectors, and vectors, and records. The behavior of eq? on number objects and characters is implementation-dependent, but it always returns either #t or #f, and returns #t only when eqv? would also return #t. The eq? predicate may also behave differently from eqv? on empty vectors, empty bytevectors, and empty strings.

    (rnrs base (6)) procedure (equal? obj1 obj2 ) ⟹ boolean?

    The equal? predicate returns #t if and only if the (possibly infinite) unfoldings of its arguments into regular trees are equal as ordered trees.

    The equal? predicate treats pairs and vectors as nodes with outgoing edges, uses string=? to compare strings, uses bytevector=? to compare bytevectors (see library chapter on “Bytevectors”), and uses eqv? to compare other nodes.

    (rnrs base (6)) procedure (eqv? obj1 obj2 ) ⟹ boolean?

    The eqv? procedure defines a useful equivalence relation on objects. Briefly, it returns #t if obj1 and obj2 should normally be regarded as the same object and #f otherwise. This relation is left slightly open to interpretation, but the following partial specification of eqv? must hold for all implementations.

    The eqv? procedure returns #t if one of the following holds:

  • Obj1 and obj2 are both booleans and are the same according to the boolean=? procedure (section 11.8).
  • Obj1 and obj2 are both symbols and are the same according to the symbol=? procedure (section 11.10).
  • Obj1 and obj2 are both exactnumber objects and are numerically equal (see =, section 11.7).
  • Obj1 and obj2 are both inexactnumber objects, are numerically equal (see =, section 11.7), and yield the same results (in the sense of eqv?) when passed as arguments to any other procedure that can be defined as a finite composition of Scheme's standard arithmetic procedures.
  • Obj1 and obj2 are both characters and are the same character according to the char=? procedure (section 11.11).
  • Both obj1 and obj2 are the empty list.
  • Obj1 and obj2 are objects such as pairs, vectors, bytevectors (library chapter on “Bytevectors”), strings, hashtables, records (library chapter on “Records”), ports (library section on “Port I/O”), or hashtables (library chapter on “Hash tables”) that refer to the same locations in the store (section 5.10).
  • Obj1 and obj2 are record-type descriptors that are specified to be eqv? in library section on “Procedural layer”.
  • The eqv? procedure returns #f if one of the following holds:

  • Obj1 and obj2 are of different types (section 11.1).
  • Obj1 and obj2 are booleans for which the boolean=? procedure returns #f.
  • Obj1 and obj2 are symbols for which the symbol=? procedure returns #f.
  • One of obj1 and obj2 is an exact number object but the other is an inexact number object.
  • Obj1 and obj2 are rational number objects for which the = procedure returns #f.
  • Obj1 and obj2 yield different results (in the sense of eqv?) when passed as arguments to any other procedure that can be defined as a finite composition of Scheme's standard arithmetic procedures.
  • Obj1 and obj2 are characters for which the char=? procedure returns #f.
  • One of obj1 and obj2 is the empty list, but the other is not.
  • Obj1 and obj2 are objects such as pairs, vectors, bytevectors (library chapter on “Bytevectors”), strings, records (library chapter on “Records”), ports (library section on “Port I/O”), or hashtables (library chapter on “Hashtables”) that refer to distinct locations.
  • Obj1 and obj2 are pairs, vectors, strings, or records, or hashtables, where the applying the same accessor (i.e. car, cdr, vector-ref, string-ref, or record accessors) to both yields results for which eqv? returns #f.
  • Obj1 and obj2 are procedures that would behave differently (return different values or have different side effects) for some arguments.
  • Note:‌ The eqv? procedure returning #t when obj1 and obj2 are number objects does not imply that = would also return #t when called with obj1 and obj2 as arguments.

    (rnrs base (6)) procedure (error (who (or string?symbol?#f)) (message string?) irritant1 ... ) ⟹ undefined

    The error procedure should be called when an error has occurred, typically caused by something that has gone wrong in the interaction of the program with the external world or the user.

    The who argument should describe the procedure or operation that detected the exception. The message argument should describe the exceptional situation. The irritants should be the arguments to the operation that detected the operation.

    The condition object provided with the exception (see library chapter on “Exceptions and conditions”) has the following condition types:

  • If who is not #f, the condition has condition type &who, with who as the value of its field. In that case, who should be the name of the procedure or entity that detected the exception. If it is #f, the condition does not have condition type &who.
  • The condition has condition type &message, with message as the value of its field.
  • The condition has condition type &irritants, and its field has as its value a list of the irritants.
  • Moreover, the condition created by error has condition type &error.

    (rnrs base (6)) procedure (exact (z number?) ) ⟹ exact?

    The exact procedure returns an exact representation of z. The value returned is the exact number object that is numerically closest to the argument; in most cases, the result of this procedure should be numerically equal to its argument. If an inexact argument has no reasonably close exact equivalent, an exception with condition type &implementation-violation may be raised.

    (rnrs base (6)) procedure (exact-integer-sqrt (k integer?) ) ⟹ (values integer?integer?)

    The exact-integer-sqrt procedure returns two non-negative exact integer objects s and r where k = s^2 + r and k < (s + 1)^2.

    (rnrs base (6)) procedure (exact? (z number?) ) ⟹ boolean?

    Tests for the exactness of a quantity. For any number object, precisely one of exact? or inexact? predicates is true.

    (rnrs base (6)) procedure (expt (z1 number?) (z2 number?) ) ⟹ number?

    Returns z1 raised to the power z2. For nonzero z1, this is ez2 log z1. 0.0z is 1.0 if z = 0.0, and 0.0 if (real-part z) is positive. For other cases in which the first argument is zero, either an exception is raised with condition type &implementation-restriction, or an unspecified number object is returned.

    For an exact real number object z1 and an exact integer object z2, (expt z1 z2) must return an exact result. For all other values of z1 and z2, (expt z1 z2) may return an inexact result, even when both z1 and z2 are exact.

    (rnrs base (6)) procedure (floor (x real?) ) ⟹ integer?

    floor returns the largest integer object not larger than x.

    (rnrs base (6)) procedure (for-each (proc procedure?) (list1 list?) (list2 list?) ... ) ⟹ undefined

    (proc obj1 obj2 ... ) ⟹ undefined

    The lists should all have the same length. Proc should accept as many arguments as there are lists. Proc should not mutate any of the lists.

    The for-each procedure applies proc element-wise to the elements of the lists for its side effects, in order from the first elements to the last. Proc is always called in the same dynamic environment as for-each itself. The return values of for-each are unspecified.

    (rnrs base (6)) procedure (gcd (n integer?) ... ) ⟹ integer?

    Returns the greatest common divisor of its arguments. The result is always non-negative.

    (rnrs base (6)) syntax (identifier-syntax (set! ) ((_ template) transformer-spec) ((_ (id1 template1) ((set! id2 pattern) template2))) )

    _ identifier constant (pattern ...) (pattern pattern ... . pattern) (pattern ... pattern ellipsis pattern ...) (pattern ... pattern ellipsis pattern ... . pattern) #(pattern ...) #(pattern ... pattern ellipsis pattern ...)

    identifier constant (element ...) (element element ... . template) (ellipsis template) #(element ...)

    Semantics: When a keyword is bound to a transformer produced by the first form of identifier-syntax, references to the keyword within the scope of the binding are replaced by <template>.

    The second, more general, form of identifier-syntax permits the transformer to determine what happens when set! is used. In this case, uses of the identifier by itself are replaced by <template1>, and uses of set! with the identifier are replaced by <template2>.

    (rnrs base (6)) syntax (if () ((_ test consequent)) ((_ test consequent alternate)) )

    An if expression is evaluated as follows: first, <test> is evaluated. If it yields a true value(see section 5.7), then <consequent> is evaluated and its values are returned. Otherwise <alternate> is evaluated and its values are returned. If <test> yields #f and no <alternate> is specified, then the result of the expression is unspecified.

    (rnrs base (6)) procedure (inexact (z number?) ) ⟹ inexact?

    The inexact procedure returns an inexact representation of z. If inexact number objects of the appropriate type have bounded precision, then the value returned is an inexact number object that is nearest to the argument. If an exact argument has no reasonably close inexact equivalent, an exception with condition type &implementation-violation may be raised.

    (rnrs base (6)) procedure (inexact? (z number?) ) ⟹ boolean?

    Tests for the exactness of a quantity. For any number object, precisely one of exact? or inexact? predicates is true.

    (rnrs base (6)) procedure (integer-valued? obj ) ⟹ boolean?

    integer-valued? procedures return #t if the object is a number object and is equal in the sense of = to some integer

    (rnrs base (6)) procedure (integer->char (n integer?) ) ⟹ char?

    For a Unicode scalar value, integer->char returns its associated character.

    (rnrs base (6)) syntax (lambda () ((_ formals body) procedure?) )

    (variable1 ...) variable (variable1 ... variable_n . variable_n+1)

    Semantics: A lambda expression evaluates to a procedure. The environment in effect when the lambda expression is evaluated is remembered as part of the procedure. When the procedure is later called with some arguments, the environment in which the lambda expression was evaluated is extended by binding the variables in the parameter list to fresh locations, and the resulting argument values are stored in those locations. Then, the expressions in the body of the lambda expression (which may contain definitions and thus represent a letrec* form, see section 11.3) are evaluated sequentially in the extended environment. The results of the last expression in the body are returned as the results of the procedure call.

    <Formals> must have one of the following forms:

  • (<variable1> ...): The procedure takes a fixed number of arguments; when the procedure is called, the arguments are stored in the bindings of the corresponding variables.
  • <variable>: The procedure takes any number of arguments; when the procedure is called, the sequence of arguments is converted into a newly allocated list, and the list is stored in the binding of the <variable>.
  • (<variable1> ... <variablen> . <variablen+1>): If a period . precedes the last variable, then the procedure takes n or more arguments, where n is the number of parameters before the period (there must be at least one). The value stored in the binding of the last variable is a newly allocated list of the arguments left over after all the other arguments have been matched up against the other parameters.
  • Any <variable> must not appear more than once in <formals>.

    (rnrs base (6)) procedure (lcm (n integer?) ... ) ⟹ integer?

    Returns the least common multiple of its arguments. The result is always non-negative.

    (rnrs base (6)) procedure (length (list list?) ) ⟹ integer?

    Returns the length of list.

    (rnrs base (6)) syntax (let () ((_ ((var1 init1) ...) body)) ((_ name ((var1 init1) ...) body)) )

    The <init>s are evaluated in the current environment (in some unspecified order), the <variable>s are bound to fresh locations holding the results, the <body> is evaluated in the extended environment, and the values of the last expression of <body> are returned. Each binding of a <variable> has <body> as its region.

    “Named let” is a variant on the syntax of let that provides a general looping construct and may also be used to express recursion. It has the same syntax and semantics as ordinary let except that <variable> is bound within <body> to a procedure whose parameters are the bound variables and whose body is <body>. Thus the execution of <body> may be repeated by invoking the procedure named by <variable>.

    (rnrs base (6)) syntax (let* () ((_ bindings body)) )

    ((variable1 init1) ...)

    The let* form is similar to let, but the <init>s are evaluated and bindings created sequentially from left to right, with the regionof each binding including the bindings to its right as well as <body>. Thus the second <init> is evaluated in an environment in which the first binding is visible and initialized, and so on.

    (rnrs base (6)) syntax (let*-values () ((_ mv-binding-spec body)) )

    ((formals1 init1) ...)

    (variable1 ...) variable (variable1 ... variable_n . variable_n+1)

    The let*-values form is similar to let-values, but the <init>s are evaluated and bindings created sequentially from left to right, with the regionof the bindings of each <formals> including the bindings to its right as well as <body>. Thus the second <init> is evaluated in an environment in which the bindings of the first <formals> is visible and initialized, and so on.

    (rnrs base (6)) syntax (let-syntax () ((_ bindings form ...)) )

    ((keyword transformer-spec) ...)

    transformer-spec ⟹ transformer-spec

    Each <keyword> is an identifier, and each <expression> is an expression that evaluates, at macro-expansion time, to a transformer. Transformers may be created by syntax-rules or identifier-syntax (see section 11.19) or by one of the other mechanisms described in library chapter on “syntax-case”. It is a syntax violation for <keyword> to appear more than once in the list of keywords being bound.

    Semantics: The <form>s are expanded in the syntactic environment obtained by extending the syntactic environment of the let-syntax form with macros whose keywords are the <keyword>s, bound to the specified transformers. Each binding of a <keyword> has the <form>s as its region.

    The <form>s of a let-syntax form are treated, whether in definition or expression context, as if wrapped in an implicit begin; see section 11.4.7. Thus definitions in the result of expanding the <form>s have the same region as any definition appearing in place of the let-syntax form would have.

    Implementation responsibilities: The implementation should detect if the value of <expression> cannot possibly be a transformer.

    (rnrs base (6)) syntax (let-values () ((_ mv-binding-spec body)) )

    ((formals1 init1) ...)

    (variable1 ...) variable (variable1 ... variable_n . variable_n+1)

    The <init>s are evaluated in the current environment (in some unspecified order), and the variables occurring in the <formals> are bound to fresh locations containing the values returned by the <init>s, where the <formals> are matched to the return values in the same way that the <formals> in a lambda expression are matched to the arguments in a procedure call. Then, the <body> is evaluated in the extended environment, and the values of the last expression of <body> are returned. Each binding of a variable has <body> as its region.If the <formals> do not match, an exception with condition type &assertion is raised.

    (rnrs base (6)) syntax (letrec () ((_ bindings body)) )

    ((variable1 init1) ...)

    The <variable>s are bound to fresh locations, the <init>s are evaluated in the resulting environment (in some unspecified order), each <variable> is assigned to the result of the corresponding <init>, the <body> is evaluated in the resulting environment, and the values of the last expression in <body> are returned. Each binding of a <variable> has the entire letrec expression as its region, making it possible to define mutually recursive procedures.

    (rnrs base (6)) syntax (letrec* () ((_ bindings body)) )

    ((variable1 init1) ...)

    The <variable>s are bound to fresh locations, each <variable> is assigned in left-to-right order to the result of evaluating the corresponding <init>, the <body> is evaluated in the resulting environment, and the values of the last expression in <body> are returned. Despite the left-to-right evaluation and assignment order, each binding of a <variable> has the entire letrec* expression as its region, making it possible to define mutually recursive procedures.

    (rnrs base (6)) syntax (letrec-syntax () ((_ bindings form ...)) )

    ((keyword transformer-spec) ...)

    The <form>s of a letrec-syntax form are treated, whether in definition or expression context, as if wrapped in an implicit begin; see section 11.4.7. Thus definitions in the result of expanding the <form>s have the same region as any definition appearing in place of the letrec-syntax form would have.

    Implementation responsibilities: The implementation should detect if the value of <expression> cannot possibly be a transformer.

    (rnrs base (6)) procedure (list obj ... ) ⟹ list?

    Returns a newly allocated list of its arguments.

    (rnrs base (6)) procedure (list->string (list list?) ) ⟹ string?

    list ⟹ (list char?)

    The list->string procedure returns a newly allocated string formed from the characters in list.

    (rnrs base (6)) procedure (list->vector (list list?) ) ⟹ vector?

    The list->vector procedure returns a newly created vector initialized to the elements of the list list.

    (rnrs base (6)) procedure (list-ref (list list?) (k integer?) ) ⟹ *

    List must be a list whose length is at least k + 1. The list-tail procedure returns the kth element of list.

    (rnrs base (6)) procedure (list-tail (list list?) (k integer?) ) ⟹ list?

    List should be a list of size at least k. The list-tail procedure returns the subchain of pairs of list obtained by omitting the first k elements.

    (rnrs base (6)) procedure (list? obj ) ⟹ boolean?

    Returns #t if obj is a list, #f otherwise. By definition, all lists are chains of pairs that have finite length and are terminated by the empty list.

    (rnrs base (6)) procedure (make-string (k integer?) ) ⟹ string?

    (rnrs base (6)) procedure (make-string (k integer?) (char char?) ) ⟹ string?

    Returns a newly allocated string of length k. If char is given, then all elements of the string are initialized to char, otherwise the contents of the string are unspecified.

    (rnrs base (6)) procedure (make-vector (k integer?) ) ⟹ vector?

    (rnrs base (6)) procedure (make-vector (k integer?) fill ) ⟹ vector?

    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.

    (rnrs base (6)) procedure (map (proc procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?

    (proc obj1 obj2 ... ) ⟹ *

    The lists should all have the same length. Proc should accept as many arguments as there are lists and return a single value. Proc should not mutate any of the lists.

    The map procedure applies proc element-wise to the elements of the lists and returns a list of the results, in order. Proc is always called in the same dynamic environment as map itself. The order in which proc is applied to the elements of the lists is unspecified. If multiple returns occur from map, the values returned by earlier returns are not mutated.

    (rnrs base (6)) procedure (max (x1 real?) (x2 real?) ... ) ⟹ real?

    Returns the maximum of its arguments.

    (rnrs base (6)) procedure (min (x1 real?) (x2 real?) ... ) ⟹ real?

    Returns the minimum of its arguments.

    (rnrs base (6)) procedure (mod (x1 real?) (x2 real?) ) ⟹ real?

    Number-theoretic integer division and return the results of the corresponding mathematical operations specified in section 11.7.3.1. x1 must be neither infinite nor a NaN, and x2 must be nonzero; otherwise, an exception with condition type &assertion is raised.

    (rnrs base (6)) procedure (mod0 (x1 real?) (x2 real?) ) ⟹ real?

    Number-theoretic integer division and return the results of the corresponding mathematical operations specified in section 11.7.3.1. x1 must be neither infinite nor a NaN, and x2 must be nonzero; otherwise, an exception with condition type &assertion is raised.

    (rnrs base (6)) procedure (not obj ) ⟹ boolean?

    Returns #t if obj is #f, and returns #f otherwise.

    (rnrs base (6)) procedure (null? obj ) ⟹ boolean?

    Returns #t if obj is the empty list, #f otherwise.

    (rnrs base (6)) procedure (number->string (z number?) ) ⟹ string?

    (rnrs base (6)) procedure (number->string (z number?) (radix integer?) ) ⟹ string?

    (rnrs base (6)) procedure (number->string (z number?) (radix integer?) (precision integer?) ) ⟹ string?

    Radix must be an exact integer object, either 2, 8, 10, or 16. If omitted, radix defaults to 10. If a precision is specified, then z must be an inexact complex number object, precision must be an exact positive integer object, and radix must be 10. The number->string procedure takes a number object and a radix and returns as a string an external representation of the given number object in the given radix such that

    (let ((number z) (radix radix)) (eqv? (string->number (number->string number radix) radix) number))

    is true. If no possible result makes this expression true, an exception with condition type &implementation-restriction is raised.

    Note:‌ The error case can occur only when z is not a complex number object or is a complex number object with a non-rational real or imaginary part.

    If a precision is specified, then the representations of the inexact real components of the result, unless they are infinite or NaN, specify an explicit <mantissa width> p, and p is the least p ≥ precision for which the above expression is true.

    If z is inexact, the radix is 10, and the above expression and condition can be satisfied by a result that contains a decimal point, then the result contains a decimal point and is expressed using the minimum number of digits (exclusive of exponent, trailing zeroes, and mantissa width) needed to make the above expression and condition true [4, 7]; otherwise the format of the result is unspecified.

    The result returned by number->string never contains an explicit radix prefix.

    (rnrs base (6)) procedure (pair? obj ) ⟹ boolean?

    Returns #t if obj is a pair, and otherwise returns #f.

    (rnrs base (6)) procedure (procedure? obj ) ⟹ boolean?

    Returns #t if obj is a procedure, otherwise returns #f.

    (rnrs base (6)) syntax (quasiquote () ((_ qq-template)) )

    “Backquote” or “quasiquote”expressions are useful for constructing a list or vector structure when some but not all of the desired structure is known in advance.

    Syntax: <Qq template> should be as specified by the grammar at the end of this entry.

    Semantics: If no unquote or unquote-splicing forms appear within the <qq template>, the result of evaluating (quasiquote <qq template>) is equivalent to the result of evaluating (quote <qq template>).

    If an (unquote <expression> ...) form appears inside a <qq template>, however, the <expression>s are evaluated (“unquoted”) and their results are inserted into the structure instead of the unquote form.

    If an (unquote-splicing <expression> ...) form appears inside a <qq template>, then the <expression>s must evaluate to lists; the opening and closing parentheses of the lists are then “stripped away” and the elements of the lists are inserted in place of the unquote-splicing form.

    Any unquote-splicing or multi-operand unquote form must appear only within a list or vector <qq template>.

    As noted in section 4.3.5, (quasiquote <qq template>) may be abbreviated `<qq template>, (unquote <expression>) may be abbreviated ,<expression>, and (unquote-splicing <expression>) may be abbreviated ,@<expression>.

    Quasiquote forms may be nested. Substitutions are made only for unquoted components appearing at the same nesting level as the outermost quasiquote. The nesting level increases by one inside each successive quasiquotation, and decreases by one inside each unquotation.

    A quasiquote expression may return either fresh, mutable objects or literal structure for any structure that is constructed at run time during the evaluation of the expression. Portions that do not need to be rebuilt are always literal. Thus,

    (let ((a 3)) `((1 2) ,a ,4 ,'five 6))

    may be equivalent to either of the following expressions:

    '((1 2) 3 4 five 6)

    (let ((a 3)) 

      (cons '(1 2)

            (cons a (cons 4 (cons 'five '(6))))))

    However, it is not equivalent to this expression:

    (let ((a 3)) (list (list 1 2) a 4 'five 6))

    It is a syntax violation if any of the identifiers quasiquote, unquote, or unquote-splicing appear in positions within a <qq template> otherwise than as described above.

    In <quasiquotation>s, a <list qq template D> can sometimes be confused with either an <unquotation D> or a <splicing unquotation D>. The interpretation as an <unquotation> or <splicing unquotation D> takes precedence.

    (rnrs base (6)) syntax (quote () ((_ datum)) )

    (quote <datum>) evaluates to the datum value represented by <datum> (see section 4.3). This notation is used to include constants. As noted in section 4.3.5, (quote <datum>) may be abbreviated as '<datum>. As noted in section 5.10, constants are immutable.

    Note:‌ Different constants that are the value of a quote expression may share the same locations.

    (rnrs base (6)) procedure (rational-valued? obj ) ⟹ boolean?

    Return #t if the object is a number object and is equal in the sense of = to some rational number.

    (rnrs base (6)) procedure (rationalize (x1 real?) (x2 real?) ) ⟹ rational?

    The rationalize procedure returns the a number object representing the simplest rational number differing from x1 by no more than x2. A rational number r1 is simpler than another rational number r2 if r1 = p1/q1 and r2 = p2/q2 (in lowest terms) and |p1| ≤ |p2| and |q1| ≤ |q2|. Thus 3/5 is simpler than 4/7. Although not all rationals are comparable in this ordering (consider 2/7 and 3/5) any interval contains a rational number that is simpler than every other rational number in that interval (the simpler 2/5 lies between 2/7 and 3/5). Note that 0 = 0/1 is the simplest rational of all.

    (rnrs base (6)) procedure (real-valued? obj ) ⟹ boolean?

    The real-valued? procedure returns #t if the object is a number object and is equal in the sense of = to some real number object, or if the object is a NaN, or a complex number object whose real part is a NaN and whose imaginary part is zero in the sense of zero?.

    (rnrs base (6)) procedure (reverse (list list?) ) ⟹ list?

    Returns a newly allocated list consisting of the elements of list in reverse order.

    (rnrs base (6)) procedure (round (x real?) ) ⟹ integer?

    The round procedure returns the closest integer object to x, rounding to even when x represents a number halfway between two integers.

    (rnrs base (6)) syntax (set! () ((_ variable expression)) )

    <Expression> is evaluated, and the resulting value is stored in the location to which <variable> is bound. <Variable> must be bound either in some regionenclosing the set! expression or at the top level. The result of the set! expression is unspecified.

    It is a syntax violation if <variable> refers to an immutable binding.

    (rnrs base (6)) procedure (sqrt (z number?) ) ⟹ number?

    Returns the principal square root of z. For rational z, the result has either positive real part, or zero real part and non-negative imaginary part. With log defined as in section 11.7.3.2, the value of (sqrt z) could be expressed as e^(log z/2).

    The sqrt procedure may return an inexact result even when given an exact argument.

    (rnrs base (6)) procedure (string (char char?) ... ) ⟹ string?

    Returns a newly allocated string composed of the arguments.

    (rnrs base (6)) procedure (string->list (string string?) ) ⟹ list?

    The string->list procedure returns a newly allocated list of the characters that make up the given string.

    (rnrs base (6)) procedure (string->number (string string?) ) ⟹ number?

    (rnrs base (6)) procedure (string->number (string string?) (radix integer?) ) ⟹ number?

    Returns a number object with maximally precise representation expressed by the given string. Radix must be an exact integer object, either 2, 8, 10, or 16. If supplied, radix is a default radix that may be overridden by an explicit radix prefix in string (e.g., "#o177"). If radix is not supplied, then the default radix is 10. If string is not a syntactically valid notation for a number object or a notation for a rational number object with a zero denominator, then string->number returns #f.

    (rnrs base (6)) procedure (string->symbol (string string?) ) ⟹ symbol?

    Returns the symbol whose name is string.

    (rnrs base (6)) procedure (string-append (string string?) ... ) ⟹ string?

    Returns a newly allocated string whose characters form the concatenation of the given strings.

    (rnrs base (6)) procedure (string-copy (string string?) ) ⟹ string?

    Returns a newly allocated copy of the given string.

    (rnrs base (6)) procedure (string-for-each (proc procedure?) (string1 string?) (string2 string?) ... ) ⟹ undefined

    (proc (string string?) ... ) ⟹ undefined

    The strings must all have the same length. Proc should accept as many arguments as there are strings. The string-for-each procedure applies proc element-wise to the characters of the strings for its side effects, in order from the first characters to the last. Proc is always called in the same dynamic environment as string-for-each itself. The return values of string-for-each are unspecified.

    Analogous to for-each.

    Implementation responsibilities: The implementation must check the restrictions on proc to the extent performed by applying it as described. An implementation may check whether proc is an appropriate argument before applying it.

    (rnrs base (6)) procedure (string-length (string string?) ) ⟹ integer?

    Returns the number of characters in the given string as an exact integer object.

    (rnrs base (6)) procedure (string-ref (string string?) (k integer?) ) ⟹ char?

    K must be a valid index of string. The string-ref procedure returns character

    k of string using zero-origin indexing.

    Note:‌ Implementors should make string-ref run in constant time.

    (rnrs base (6)) procedure (string<=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?

    Lexicographic extension to strings of the corresponding orderings on characters. If two strings differ in length but are the same up to the length of the shorter string, the shorter string is considered to be lexicographically less than the longer string.

    (rnrs base (6)) procedure (string<? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?

    Lexicographic extension to strings of the corresponding orderings on characters. If two strings differ in length but are the same up to the length of the shorter string, the shorter string is considered to be lexicographically less than the longer string.

    (rnrs base (6)) procedure (string=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?

    Returns #t if the strings are the same length and contain the same characters in the same positions. Otherwise, the string=? procedure returns #f.

    (rnrs base (6)) procedure (string>=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?

    Lexicographic extension to strings of the corresponding orderings on characters. If two strings differ in length but are the same up to the length of the shorter string, the shorter string is considered to be lexicographically less than the longer string.

    (rnrs base (6)) procedure (string>? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?

    Lexicographic extension to strings of the corresponding orderings on characters. If two strings differ in length but are the same up to the length of the shorter string, the shorter string is considered to be lexicographically less than the longer string.

    (rnrs base (6)) procedure (string? obj ) ⟹ boolean?

    Returns #t if obj is a string, otherwise returns #f.

    (rnrs base (6)) procedure (substring (string string?) (start integer?) (end integer?) ) ⟹ string?

    String must be a string, and start and end must be exact integer objects satisfying

    0 ≤ start ≤ end ≤ (string-length string).

    The substring procedure returns a newly allocated string formed from the characters of string beginning with index start (inclusive) and ending with index end (exclusive).

    (rnrs base (6)) procedure (symbol->string (symbol symbol?) ) ⟹ string?

    Returns the name of symbol as an immutable string.

    (rnrs base (6)) procedure (symbol=? (symbol1 symbol?) (symbol2 symbol?) (symbol3 symbol?) ... ) ⟹ boolean?

    Returns #t if the symbols are the same, i.e., if their names are spelled the same.

    (rnrs base (6)) procedure (symbol? obj ) ⟹ boolean?

    Returns #t if obj is a symbol, otherwise returns #f.

    (rnrs base (6)) syntax (syntax-rules (_ ) ((_ (literal ...) syntax-rule ...) transformer-spec) )

    (pattern template)

    _ identifier constant (pattern ...) (pattern pattern ... . pattern) (pattern ... pattern ellipsis pattern ...) (pattern ... pattern ellipsis pattern ... . pattern) #(pattern ...) #(pattern ... pattern ellipsis pattern ...)

    identifier constant (element ...) (element element ... . template) (ellipsis template) #(element ...)

    template template ellipsis

    Semantics: An instance of syntax-rules evaluates, at macro-expansion time, to a new macro transformer by specifying a sequence of hygienic rewrite rules. A use of a macro whose keyword is associated with a transformer specified by syntax-rules is matched against the patterns contained in the <syntax rule>s, beginning with the leftmost <syntax rule>. When a match is found, the macro use is transcribed hygienically according to the template. It is a syntax violation when no match is found.

    An identifier appearing within a <pattern> may be an underscore ( _ ), a literal identifier listed in the list of literals (<literal> ...), or an ellipsis ( ... ). All other identifiers appearing within a <pattern> are pattern variables. It is a syntax violation if an ellipsis or underscore appears in (<literal> ...).

    While the first subform of <srpattern> may be an identifier, the identifier is not involved in the matching and is not considered a pattern variable or literal identifier.

    Pattern variables match arbitrary input subforms and are used to refer to elements of the input. It is a syntax violation if the same pattern variable appears more than once in a <pattern>.

    Underscores also match arbitrary input subforms but are not pattern variables and so cannot be used to refer to those elements. Multiple underscores may appear in a <pattern>.

    A literal identifier matches an input subform if and only if the input subform is an identifier and either both its occurrence in the input expression and its occurrence in the list of literals have the same lexical binding, or the two identifiers have the same name and both have no lexical binding.

    A subpattern followed by an ellipsis can match zero or more elements of the input.

    More formally, an input form F matches a pattern P if and only if one of the following holds:

  • P is an underscore ( _ ).
  • P is a pattern variable.
  • P is a literal identifier and F is an identifier such that both P and F would refer to the same binding if both were to appear in the output of the macro outside of any bindings inserted into the output of the macro. (If neither of two like-named identifiers refers to any binding, i.e., both are undefined, they are considered to refer to the same binding.)
  • P is of the form (P1 ... Pn) and F is a list of n elements that match P1 through Pn.
  • P is of the form (P1 ... Pn . Px) and F is a list or improper list of n or more elements whose first n elements match P1 through Pn and whose nth cdr matches Px.
  • P is of the form (P1 ... Pk Pe <ellipsis> Pm+1 ... Pn), where <ellipsis> is the identifier ... and F is a list of n elements whose first k elements match P1 through Pk, whose next m−k elements each match Pe, and whose remaining n−m elements match Pm+1 through Pn.
  • P is of the form (P1 ... Pk Pe <ellipsis> Pm+1 ... Pn . Px), where <ellipsis> is the identifier ... and F is a list or improper list of n elements whose first k elements match P1 through Pk, whose next m−k elements each match Pe, whose next n−m elements match Pm+1 through Pn, and whose nth and final cdr matches Px.
  • P is of the form #(P1 ... Pn) and F is a vector of n elements that match P1 through Pn.
  • P is of the form #(P1 ... Pk Pe <ellipsis> Pm+1 ... Pn), where <ellipsis> is the identifier ... and F is a vector of n or more elements whose first k elements match P1 through Pk, whose next m−k elements each match Pe, and whose remaining n−m elements match Pm+1 through Pn.
  • P is a pattern datum (any nonlist, nonvector, nonsymbol datum) and F is equal to P in the sense of the equal? procedure.
  • When a macro use is transcribed according to the template of the matching <syntax rule>, pattern variables that occur in the template are replaced by the subforms they match in the input.

    Pattern data and identifiers that are not pattern variables or ellipses are copied into the output. A subtemplate followed by an ellipsis expands into zero or more occurrences of the subtemplate. Pattern variables that occur in subpatterns followed by one or more ellipses may occur only in subtemplates that are followed by (at least) as many ellipses. These pattern variables are replaced in the output by the input subforms to which they are bound, distributed as specified. If a pattern variable is followed by more ellipses in the subtemplate than in the associated subpattern, the input form is replicated as necessary. The subtemplate must contain at least one pattern variable from a subpattern followed by an ellipsis, and for at least one such pattern variable, the subtemplate must be followed by exactly as many ellipses as the subpattern in which the pattern variable appears. (Otherwise, the expander would not be able to determine how many times the subform should be repeated in the output.) It is a syntax violation if the constraints of this paragraph are not met.

    A template of the form (<ellipsis> <template>) is identical to <template>, except that ellipses within the template have no special meaning. That is, any ellipses contained within <template> are treated as ordinary identifiers. In particular, the template (... ...) produces a single ellipsis, .... This allows syntactic abstractions to expand into forms containing ellipses.

    (rnrs base (6)) procedure (truncate (x real?) ) ⟹ integer?

    The truncate procedure returns the integer object closest to x whose absolute value is not larger than the absolute value of x.

    (rnrs base (6)) syntax (unquote () ((_ expression)) )

    “Backquote” or “quasiquote”expressions are useful for constructing a list or vector structure when some but not all of the desired structure is known in advance.

    Syntax: <Qq template> should be as specified by the grammar at the end of this entry.

    Semantics: If no unquote or unquote-splicing forms appear within the <qq template>, the result of evaluating (quasiquote <qq template>) is equivalent to the result of evaluating (quote <qq template>).

    If an (unquote <expression> ...) form appears inside a <qq template>, however, the <expression>s are evaluated (“unquoted”) and their results are inserted into the structure instead of the unquote form.

    If an (unquote-splicing <expression> ...) form appears inside a <qq template>, then the <expression>s must evaluate to lists; the opening and closing parentheses of the lists are then “stripped away” and the elements of the lists are inserted in place of the unquote-splicing form.

    Any unquote-splicing or multi-operand unquote form must appear only within a list or vector <qq template>.

    As noted in section 4.3.5, (quasiquote <qq template>) may be abbreviated `<qq template>, (unquote <expression>) may be abbreviated ,<expression>, and (unquote-splicing <expression>) may be abbreviated ,@<expression>.

    Quasiquote forms may be nested. Substitutions are made only for unquoted components appearing at the same nesting level as the outermost quasiquote. The nesting level increases by one inside each successive quasiquotation, and decreases by one inside each unquotation.

    A quasiquote expression may return either fresh, mutable objects or literal structure for any structure that is constructed at run time during the evaluation of the expression. Portions that do not need to be rebuilt are always literal. Thus,

    (let ((a 3)) `((1 2) ,a ,4 ,'five 6))

    may be equivalent to either of the following expressions:

    '((1 2) 3 4 five 6)

    (let ((a 3)) 

      (cons '(1 2)

            (cons a (cons 4 (cons 'five '(6))))))

    However, it is not equivalent to this expression:

    (let ((a 3)) (list (list 1 2) a 4 'five 6))

    It is a syntax violation if any of the identifiers quasiquote, unquote, or unquote-splicing appear in positions within a <qq template> otherwise than as described above.

    In <quasiquotation>s, a <list qq template D> can sometimes be confused with either an <unquotation D> or a <splicing unquotation D>. The interpretation as an <unquotation> or <splicing unquotation D> takes precedence.

    (rnrs base (6)) syntax (unquote-splicing () ((_ expression)) )

    “Backquote” or “quasiquote”expressions are useful for constructing a list or vector structure when some but not all of the desired structure is known in advance.

    Syntax: <Qq template> should be as specified by the grammar at the end of this entry.

    Semantics: If no unquote or unquote-splicing forms appear within the <qq template>, the result of evaluating (quasiquote <qq template>) is equivalent to the result of evaluating (quote <qq template>).

    If an (unquote <expression> ...) form appears inside a <qq template>, however, the <expression>s are evaluated (“unquoted”) and their results are inserted into the structure instead of the unquote form.

    If an (unquote-splicing <expression> ...) form appears inside a <qq template>, then the <expression>s must evaluate to lists; the opening and closing parentheses of the lists are then “stripped away” and the elements of the lists are inserted in place of the unquote-splicing form.

    Any unquote-splicing or multi-operand unquote form must appear only within a list or vector <qq template>.

    As noted in section 4.3.5, (quasiquote <qq template>) may be abbreviated `<qq template>, (unquote <expression>) may be abbreviated ,<expression>, and (unquote-splicing <expression>) may be abbreviated ,@<expression>.

    Quasiquote forms may be nested. Substitutions are made only for unquoted components appearing at the same nesting level as the outermost quasiquote. The nesting level increases by one inside each successive quasiquotation, and decreases by one inside each unquotation.

    A quasiquote expression may return either fresh, mutable objects or literal structure for any structure that is constructed at run time during the evaluation of the expression. Portions that do not need to be rebuilt are always literal. Thus,

    (let ((a 3)) `((1 2) ,a ,4 ,'five 6))

    may be equivalent to either of the following expressions:

    '((1 2) 3 4 five 6)

    (let ((a 3)) 

      (cons '(1 2)

            (cons a (cons 4 (cons 'five '(6))))))

    However, it is not equivalent to this expression:

    (let ((a 3)) (list (list 1 2) a 4 'five 6))

    It is a syntax violation if any of the identifiers quasiquote, unquote, or unquote-splicing appear in positions within a <qq template> otherwise than as described above.

    In <quasiquotation>s, a <list qq template D> can sometimes be confused with either an <unquotation D> or a <splicing unquotation D>. The interpretation as an <unquotation> or <splicing unquotation D> takes precedence.

    (rnrs base (6)) procedure (values obj ... ) ⟹ (values *...)

    Delivers all of its arguments to its continuation. The continuations of all non-final expressions within a sequence of expressions, such as in lambda, begin, let, let*, letrec, letrec*, let-values, let*-values, case, and cond forms, usually take an arbitrary number of values. Except for these and the continuations created by call-with-values, let-values, and let*-values, continuations implicitly accepting a single value, such as the continuations of <operator> and <operand>s of procedure calls or the <test> expressions in conditionals, take exactly one value. The effect of passing an inappropriate number of values to such a continuation is undefined.

    (rnrs base (6)) procedure (vector obj ... ) ⟹ vector?

    Returns a newly allocated vector whose elements contain the given arguments. Analogous to list.

    (rnrs base (6)) procedure (vector->list (vector vector?) ) ⟹ list?

    The vector->list procedure returns a newly allocated list of the objects contained in the elements of vector.

    (rnrs base (6)) procedure (vector-fill! (vector vector?) fill ) ⟹ undefined

    Stores fill in every element of vector and returns unspecified values.

    (rnrs base (6)) procedure (vector-for-each (proc procedure?) (vector1 vector?) (vector2 vector?) ... ) ⟹ undefined

    (proc obj ... ) ⟹ undefined

    The vectors must all have the same length. Proc should accept as many arguments as there are vectors. The vector-for-each procedure applies proc element-wise to the elements of the vectors for its side effects, in order from the first elements to the last. Proc is always called in the same dynamic environment as vector-for-each itself. The return values of vector-for-each are unspecified.

    Analogous to for-each.

    Implementation responsibilities: The implementation must check the restrictions on proc to the extent performed by applying it as described. An implementation may check whether proc is an appropriate argument before applying it.

    (rnrs base (6)) procedure (vector-length (vector vector?) ) ⟹ integer?

    Returns the number of elements in vector as an exact integer object.

    (rnrs base (6)) procedure (vector-map (proc procedure?) (vector1 vector?) (vector2 vector?) ... ) ⟹ vector?

    (proc obj ... ) ⟹ *

    The vectors must all have the same length. Proc should accept as many arguments as there are vectors and return a single value.

    The vector-map procedure applies proc element-wise to the elements of the vectors and returns a vector of the results, in order. Proc is always called in the same dynamic environment as vector-map itself. The order in which proc is applied to the elements of the vectors is unspecified. If multiple returns occur from vector-map, the return values returned by earlier returns are not mutated.

    Analogous to map.

    Implementation responsibilities: The implementation must check the restrictions on proc to the extent performed by applying it as described. An implementation may check whether proc is an appropriate argument before applying it.

    (rnrs base (6)) procedure (vector-ref (vector vector?) (k integer?) ) ⟹ *

    K must be a valid index of vector. The vector-ref procedure returns the contents of element k of vector.

    (rnrs base (6)) procedure (vector-set! (vector vector?) (k integer?) obj ) ⟹ undefined

    K must be a valid index of vector. The vector-set! procedure stores obj in element k of vector, and returns unspecified values. Passing an immutable vector to vector-set! should cause an exception with condition type &assertion to be raised.

    (rnrs base (6)) procedure (vector? obj ) ⟹ boolean?

    Returns #t if obj is a vector. Otherwise the procedure returns #f.

    (rnrs base (6)) procedure (complex? obj ) ⟹ boolean?

    (rnrs base (6)) procedure (number? obj ) ⟹ boolean?

    (rnrs base (6)) procedure (real? obj ) ⟹ boolean?

    (rnrs base (6)) procedure (rational? obj ) ⟹ boolean?

    (rnrs base (6)) procedure (integer? obj ) ⟹ boolean?

    These numerical type predicates can be applied to any kind of argument. They return #t if the object is a number object of the named type, and #f otherwise. In general, if a type predicate is true of a number object then all higher type predicates are also true of that number object. Consequently, if a type predicate is false of a number object, then all lower type predicates are also false of that number object.

    If z is a complex number object, then (real? z ) is true if and only if (zero? (imag-part z )) and (exact? (imag-part z )) are both true.

    If x is a real number object, then (rational? x ) is true if and only if there exist exact integer objects k1 and k2 such that (= x (/ k1 k2)) and (= (numerator x ) k1) and (= (denominator x ) k2) are all true. Thus infinities and NaNs are not rational number objects.

    If q is a rational number objects, then (integer? q) is true if and only if (= (denominator q) 1) is true. If q is not a rational number object, then (integer? q) is #f.

    (rnrs base (6)) procedure (zero? (z number?) ) ⟹ boolean?

    (rnrs base (6)) procedure (positive? (x real?) ) ⟹ boolean?

    (rnrs base (6)) procedure (negative? (x real?) ) ⟹ boolean?

    (rnrs base (6)) procedure (odd? (n integer?) ) ⟹ boolean?

    (rnrs base (6)) procedure (even? (n integer?) ) ⟹ boolean?

    (rnrs base (6)) procedure (finite? (z number?) ) ⟹ boolean?

    (rnrs base (6)) procedure (infinite? (z number?) ) ⟹ boolean?

    (rnrs base (6)) procedure (nan? (z number?) ) ⟹ boolean?

    These numerical predicates test a number object for a particular property, returning #t or #f. The zero? procedure tests if the number object is = to zero, positive? tests whether it is greater than zero, negative? tests whether it is less than zero, odd? tests whether it is odd, even? tests whether it is even, finite? tests whether it is not an infinity and not a NaN, infinite? tests whether it is an infinity, nan? tests whether it is a NaN.

    (rnrs base (6)) procedure (exp (z number?) ) ⟹ number?

    (rnrs base (6)) procedure (log (z number?) ) ⟹ number?

    (rnrs base (6)) procedure (log (z1 number?) (z2 number?) ) ⟹ number?

    (rnrs base (6)) procedure (sin (z number?) ) ⟹ number?

    (rnrs base (6)) procedure (cos (z number?) ) ⟹ number?

    (rnrs base (6)) procedure (tan (z number?) ) ⟹ number?

    (rnrs base (6)) procedure (asin (z number?) ) ⟹ number?

    (rnrs base (6)) procedure (acos (z number?) ) ⟹ number?

    (rnrs base (6)) procedure (atan (z number?) ) ⟹ number?

    (rnrs base (6)) procedure (atan (x1 real?) (x2 real?) ) ⟹ number?

    These procedures compute the usual transcendental functions. The exp procedure computes the base-e exponential of z . The log procedure with a single argument computes the natural logarithm of z (not the base-ten logarithm); (log z1 z2) computes the base-z2 logarithm of z1. The asin, acos, and atan procedures compute arcsine, arccosine, and arctangent, respectively. The two-argument variant of atan computes (angle (make-rectangular x2 x1)). These procedures may return inexact results even when given exact arguments.

    (rnrs base (6)) procedure (numerator (q rational?) ) ⟹ integer?

    (rnrs base (6)) procedure (denominator (q rational?) ) ⟹ integer?

    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 denominator is always positive. The denominator of 0 is defined to be 1.

    (rnrs base (6)) procedure (make-polar (x3 real?) (x4 real?) ) ⟹ complex?

    (rnrs base (6)) procedure (make-rectangular (x1 real?) (x2 real?) ) ⟹ complex?

    (rnrs base (6)) procedure (real-part (z complex?) ) ⟹ real?

    (rnrs base (6)) procedure (imag-part (z complex?) ) ⟹ real?

    (rnrs base (6)) procedure (magnitude (z complex?) ) ⟹ real?

    (rnrs base (6)) procedure (angle (z complex?) ) ⟹ real?

    Suppose a1, a2, a3, and a4 are real numbers, and c is a complex number such that the following holds:

    c = a1 + a2*i = a3*e^(i*a4)

    Then, if x1, x2, x3, and x4 are number objects representing a1, a2, a3, and a4, respectively, (make-rectangular x1 x2) returns c, and (make-polar x3 x4) returns c.

    Conversely, if −pi <= a4 <= pi, and if z is a number object representing c, then (real-part z ) returns a1 (imag-part z ) returns a2, (magnitude z ) returns a3, and (angle z ) returns a4.

    Moreover, suppose x1, x2 are such that either x1 or x2 is an infinity, then

    (make-rectangular x1 x2) => z

    (magnitude z ) => +inf.0

    The make-polar, magnitude, and angle procedures may return inexact results even when given exact arguments.

    library (rnrs arithmetic bitwise (6))

    (rnrs arithmetic bitwise (6)) procedure (bitwise-not (ei integer?) ) ⟹ integer?

    Returns the exact integer object whose two's complement representation is the one's complement of the two's complement representation of ei.

    (rnrs arithmetic bitwise (6)) procedure (bitwise-and (i integer?) ... ) ⟹ integer?

    This procedure returns the exact integer object that is the bit-wise "and" of the two's complement representations of its arguments. If it is passed only one argument, it returns that argument. If it is passed no arguments, it returns -1 that acts as identity for the operation.

    (rnrs arithmetic bitwise (6)) procedure (bitwise-ior (i integer?) ... ) ⟹ integer?

    This procedure returns the exact integer object that is the bit-wise "inclusive-or" of the two's complement representations of its arguments. If it is passed only one argument, it returns that argument. If it is passed no arguments, it returns 0 that acts as identity for the operation.

    (rnrs arithmetic bitwise (6)) procedure (bitwise-xor (i integer?) ... ) ⟹ integer?

    This procedure returns the exact integer object that is the bit-wise "exclusive-or" of the two's complement representations of its arguments. If it is passed only one argument, it returns that argument. If it is passed no arguments, it returns 0 that acts as identity for the operation.

    (rnrs arithmetic bitwise (6)) procedure (bitwise-if (ei1 integer?) (ei2 integer?) (ei3 integer?) ) ⟹ integer?

    Returns the exact integer object that is the bit-wise "if" of the two's complement representations of its arguments, i.e. for each bit, if it is 1 in ei1, the corresponding bit in ei2 becomes the value of the corresponding bit in the result, and if it is 0, the corresponding bit in ei3 becomes the corresponding bit in the value of the result. This is the result of the following computation:

    (bitwise-ior (bitwise-and ei1 ei2) (bitwise-and (bitwise-not ei1) ei3))

    (rnrs arithmetic bitwise (6)) procedure (bitwise-bit-count (ei integer?) ) ⟹ integer?

    If ei is non-negative, this procedure returns the number of 1 bits in the two's complement representation of ei. Otherwise it returns the result of the following computation:

    (bitwise-not (bitwise-bit-count (bitwise-not ei)))

    (rnrs arithmetic bitwise (6)) procedure (bitwise-length (ei integer?) ) ⟹ integer?

    Returns the number of bits needed to represent ei if it is positive, and the number of bits needed to represent (bitwise-not ei) if it is negative.

    (rnrs arithmetic bitwise (6)) procedure (bitwise-first-bit-set (ei integer?) ) ⟹ integer?

    Returns the index of the least significant 1 bit in the two's complement representation of ei. If ei is 0, then −1 is returned.

    (rnrs arithmetic bitwise (6)) procedure (bitwise-bit-set? (ei1 integer?) (ei2 integer?) ) ⟹ boolean?

    Ei2 must be non-negative. The bitwise-bit-set? procedure returns #t if the ei2th bit is 1 in the two's complement representation of ei1, and #f otherwise.

    (rnrs arithmetic bitwise (6)) procedure (bitwise-copy-bit (ei1 integer?) (ei2 integer?) (ei3 integer?) ) ⟹ integer?

    Ei2 must be non-negative, and ei3 must be either 0 or 1. The bitwise-copy-bit procedure returns the result of replacing the ei2th bit of ei1 by the ei2th bit of ei3

    (rnrs arithmetic bitwise (6)) procedure (bitwise-bit-field (ei1 integer?) (ei2 integer?) (ei3 integer?) ) ⟹ integer?

    Ei2 and ei3 must be non-negative, and ei2 must be less than or equal to ei3. The bitwise-bit-field procedure returns the number represented by the bits at the positions from ei2 (inclusive) to ei3 (exclusive)

    (rnrs arithmetic bitwise (6)) procedure (bitwise-copy-bit-field (ei1 integer?) (ei2 integer?) (ei3 integer?) (ei4 integer?) ) ⟹ integer?

    Ei2 and ei3 must be non-negative, and ei2 must be less than or equal to ei3. The bitwise-copy-bit-field procedure returns the result of replacing in ei1 the bits at positions from ei2 (inclusive) to ei3 (exclusive) by the corresponding bits in ei4

    (rnrs arithmetic bitwise (6)) procedure (bitwise-arithmetic-shift (ei1 integer?) (ei2 integer?) ) ⟹ integer?

    Returns the result of the following computation:

    (floor (* ei1 (expt 2 ei2)))

    (rnrs arithmetic bitwise (6)) procedure (bitwise-arithmetic-shift-left (ei1 integer?) (ei2 integer?) ) ⟹ integer?

    Ei2 must be non-negative. The bitwise-arithmetic-shift-left procedure returns the same result as bitwise-arithmetic-shift

    (rnrs arithmetic bitwise (6)) procedure (bitwise-arithmetic-shift-right (ei1 integer?) (ei2 integer?) ) ⟹ integer?

    Ei2 must be non-negative. The bitwise-arithmetic-shift-left procedure returns the same result as (bitwise-arithmetic-shift ei1 (- ei2))

    (rnrs arithmetic bitwise (6)) procedure (bitwise-rotate-bit-field (ei1 integer?) (ei2 integer?) (ei3 integer?) (ei4 integer?) ) ⟹ integer?

    Ei2, ei3, ei4 must be non-negative, ei2 must be less than or equal to ei3, and ei4 must be non-negative. procedure returns the result of cyclically permuting in ei1 the bits at positions from ei2 (inclusive) to ei3 (exclusive) by ei4 bits towards the more significant bits

    (rnrs arithmetic bitwise (6)) procedure (bitwise-reverse-bit-field (ei1 integer?) (ei2 integer?) (ei3 integer?) ) ⟹ integer?

    Ei2 and ei3 must be non-negative, and ei2 must be less than or equal to ei3. The bitwise-reverse-bit-field procedure returns the result obtained from ei1 by reversing the order of the bits at positions from ei2 (inclusive) to ei3 (exclusive).

    library (rnrs arithmetic fixnums (6))

    (rnrs arithmetic fixnums (6)) procedure (fixnum? obj ) ⟹ boolean?

    Returns #t if obj is an exact integer object within the fixnum range, #f otherwise.

    (rnrs arithmetic fixnums (6)) procedure (fixnum-width ) ⟹ fixnum?

    Fixnum type size in bits

    (rnrs arithmetic fixnums (6)) procedure (least-fixnum ) ⟹ fixnum?

    Smallest fixnum value

    (rnrs arithmetic fixnums (6)) procedure (greatest-fixnum ) ⟹ fixnum?

    Biggest fixnum value

    (rnrs arithmetic fixnums (6)) procedure (fx=? (i fixnum?) ... ) ⟹ boolean?

    Return #t if arguments are equal, #f otherwise.

    (rnrs arithmetic fixnums (6)) procedure (fx<? (i fixnum?) ... ) ⟹ boolean?

    Return #t if arguments are monotonically increasing, #f otherwise.

    (rnrs arithmetic fixnums (6)) procedure (fx>? (i fixnum?) ... ) ⟹ boolean?

    Return #t if arguments are monotonically decreasing, #f otherwise.

    (rnrs arithmetic fixnums (6)) procedure (fx<=? (i fixnum?) ... ) ⟹ boolean?

    Return #t if arguments are monotonically nondecreasing, #f otherwise.

    (rnrs arithmetic fixnums (6)) procedure (fx>=? (i fixnum?) ... ) ⟹ boolean?

    Return #t if arguments are monotonically nonincreasing, #f otherwise.

    (rnrs arithmetic fixnums (6)) procedure (fxzero? (i fixnum?) ) ⟹ boolean?

    Number equal to 0?

    (rnrs arithmetic fixnums (6)) procedure (fxpositive? (i fixnum?) ) ⟹ boolean?

    Number greater than 0?

    (rnrs arithmetic fixnums (6)) procedure (fxnegative? (i fixnum?) ) ⟹ boolean?

    Number less than 0?

    (rnrs arithmetic fixnums (6)) procedure (fxodd? (i fixnum?) ) ⟹ boolean?

    Number is odd?

    (rnrs arithmetic fixnums (6)) procedure (fxeven? (i fixnum?) ) ⟹ boolean?

    Number is even?

    (rnrs arithmetic fixnums (6)) procedure (fxmax (i fixnum?) (j fixnum?) ... ) ⟹ fixnum?

    Return maximum of its arguments.

    (rnrs arithmetic fixnums (6)) procedure (fxmin (i fixnum?) (j fixnum?) ... ) ⟹ fixnum?

    Return minimum of its arguments.

    (rnrs arithmetic fixnums (6)) procedure (fx+ (i fixnum?) (j fixnum?) ) ⟹ fixnum?

    The procedure returns the sum of its arguments, provided that sum is a fixnum. An exception with condition type &implementation-restriction is raised if that sum is not a fixnum.

    (rnrs arithmetic fixnums (6)) procedure (fx* (i fixnum?) (j fixnum?) ) ⟹ fixnum?

    The procedure returns the product of its arguments, provided that product is a fixnum. An exception with condition type &implementation-restriction is raised if that product is not a fixnum.

    (rnrs arithmetic fixnums (6)) procedure (fx- (i fixnum?) (j fixnum?) ) ⟹ fixnum?

    (rnrs arithmetic fixnums (6)) procedure (fx- (i fixnum?) ) ⟹ fixnum?

    With two arguments, this procedure returns the difference fx1−fx2, provided that difference is a fixnum. With one argument, this procedure returns the additive inverse of its argument, provided that integer object is a fixnum. An exception with condition type &assertion is raised if the mathematically correct result of this procedure is not a fixnum.

    (rnrs arithmetic fixnums (6)) procedure (fxdiv (x1 fixnum?) (x2 fixnum?) ) ⟹ fixnum?

    Procedure implements number-theoretic integer division and returns the result of the mathematical operations specified in report section on “Integer division”.

    (rnrs arithmetic fixnums (6)) procedure (fxdiv0 (x1 fixnum?) (x2 fixnum?) ) ⟹ fixnum?

    Procedure implements number-theoretic integer division and returns the result of the mathematical operations specified in report section on “Integer division”.

    (rnrs arithmetic fixnums (6)) procedure (fxdiv-and-mod (x1 fixnum?) (x2 fixnum?) ) ⟹ (values fixnum?fixnum?)

    Procedure implements number-theoretic integer division and returns the result of the mathematical operations specified in report section on “Integer division”.

    (rnrs arithmetic fixnums (6)) procedure (fxdiv0-and-mod0 (x1 fixnum?) (x2 fixnum?) ) ⟹ (values fixnum?fixnum?)

    Procedure implements number-theoretic integer division and returns the result of the mathematical operations specified in report section on “Integer division”.

    (rnrs arithmetic fixnums (6)) procedure (fxmod (x1 fixnum?) (x2 fixnum?) ) ⟹ fixnum?

    Procedure implements number-theoretic integer division and returns the result of the mathematical operations specified in report section on “Integer division”.

    (rnrs arithmetic fixnums (6)) procedure (fxmod0 (x1 fixnum?) (x2 fixnum?) ) ⟹ fixnum?

    Procedure implements number-theoretic integer division and returns the result of the mathematical operations specified in report section on “Integer division”.

    (rnrs arithmetic fixnums (6)) procedure (fx+/carry (i fixnum?) (j fixnum?) (k fixnum?) ) ⟹ (values fixnum?fixnum?)

    Returns the two fixnum results of the following computation:

    (let* ((s (+ fx1 fx2 fx3))

    (s0 (mod0 s (expt 2 (fixnum-width))))

    (s1 (div0 s (expt 2 (fixnum-width)))))

    (values s0 s1))

    (rnrs arithmetic fixnums (6)) procedure (fx-/carry (i fixnum?) (j fixnum?) (k fixnum?) ) ⟹ (values fixnum?fixnum?)

    Returns the two fixnum results of the following computation:

    (let* ((d (- fx1 fx2 fx3))

    (d0 (mod0 d (expt 2 (fixnum-width))))

    (d1 (div0 d (expt 2 (fixnum-width)))))

    (values d0 d1))

    (rnrs arithmetic fixnums (6)) procedure (fx*/carry (i fixnum?) (j fixnum?) (k fixnum?) ) ⟹ (values fixnum?fixnum?)

    Returns the two fixnum results of the following computation:

    (let* ((s (+ (* fx1 fx2) fx3))

    (s0 (mod0 s (expt 2 (fixnum-width))))

    (s1 (div0 s (expt 2 (fixnum-width)))))

    (values s0 s1))

    (rnrs arithmetic fixnums (6)) procedure (fxnot (fx fixnum?) ) ⟹ fixnum?

    Returns the unique fixnum that is congruent mod 2^w to the one's-complement of fx.

    (rnrs arithmetic fixnums (6)) procedure (fxand (i fixnum?) ... ) ⟹ fixnum?

    Procedure returns the fixnum that is the bit-wise "and" of the two's complement representations of its arguments. If it is passed only one argument, it returns that argument. If it is passed no arguments, it returns -1 that acts as identity for the operation.

    (rnrs arithmetic fixnums (6)) procedure (fxior (i fixnum?) ... ) ⟹ fixnum?

    Procedure returns the fixnum that is the bit-wise "inclusive or" of the two's complement representations of its arguments. If it is passed only one argument, it returns that argument. If it is passed no arguments, it returns 0 that acts as identity for the operation.

    (rnrs arithmetic fixnums (6)) procedure (fxxor (i fixnum?) ... ) ⟹ fixnum?

    Procedure returns the fixnum that is the bit-wise "exclusive or" of the two's complement representations of its arguments. If it is passed only one argument, it returns that argument. If it is passed no arguments, it returns 0 that acts as identity for the operation.

    (rnrs arithmetic fixnums (6)) procedure (fxif (fx1 fixnum?) (fx2 fixnum?) (fx3 fixnum?) ) ⟹ fixnum?

    Returns the fixnum that is the bit-wise "if" of the two's complement representations of its arguments, i.e. for each bit, if it is 1 in fx1, the corresponding bit in fx2 becomes the value of the corresponding bit in the result, and if it is 0, the corresponding bit in fx3 becomes the corresponding bit in the value of the result.

    (rnrs arithmetic fixnums (6)) procedure (fxbit-count (fx fixnum?) ) ⟹ fixnum?

    If fx is non-negative, this procedure returns the number of 1 bits in the two's complement representation of fx. Otherwise it returns the result of the following computation:

    (fxnot (fxbit-count (fxnot ei)))

    (rnrs arithmetic fixnums (6)) procedure (fxlength (fx fixnum?) ) ⟹ fixnum?

    Returns the number of bits needed to represent fx if it is positive, and the number of bits needed to represent (fxnot fx) if it is negative.

    (rnrs arithmetic fixnums (6)) procedure (fxfirst-bit-set (fx fixnum?) ) ⟹ fixnum?

    Returns the index of the least significant 1 bit in the two's complement representation of fx. If fx is 0, then −1 is returned.

    (rnrs arithmetic fixnums (6)) procedure (fxbit-set? (fx1 fixnum?) (fx2 fixnum?) ) ⟹ boolean?

    Fx2 must be non-negative and less than (fixnum-width). The fxbit-set? procedure returns #t if the fx2th bit is 1 in the two's complement representation of fx1, and #f otherwise.

    (rnrs arithmetic fixnums (6)) procedure (fxcopy-bit (fx1 fixnum?) (fx2 fixnum?) (fx3 fixnum?) ) ⟹ fixnum?

    Fx2 must be non-negative and less than (fixnum-width). Fx3 must be 0 or 1. The fxcopy-bit procedure returns the result of replacing the fx2th bit of fx1 by fx3

    (rnrs arithmetic fixnums (6)) procedure (fxbit-field (fx1 fixnum?) (fx2 fixnum?) (fx3 fixnum?) ) ⟹ fixnum?

    Fx2 and fx3 must be non-negative and less than (fixnum-width). Moreover, fx2 must be less than or equal to fx3. The fxbit-field procedure returns the number represented by the bits at the positions from fx2 (inclusive) to fx3 (exclusive)

    (rnrs arithmetic fixnums (6)) procedure (fxcopy-bit-field (fx1 fixnum?) (fx2 fixnum?) (fx3 fixnum?) (fx4 fixnum?) ) ⟹ fixnum?

    Fx2 and fx3 must be non-negative and less than (fixnum-width). Moreover, fx2 must be less than or equal to fx3. The fxcopy-bit-field procedure returns the result of replacing in fx1 the bits at positions from fx2 (inclusive) to fx3 (exclusive) by the corresponding bits in fx4

    (rnrs arithmetic fixnums (6)) procedure (fxarithmetic-shift (fx1 fixnum?) (fx2 fixnum?) ) ⟹ fixnum?

    The absolute value of fx2 must be less than (fixnum-width). If (floor (* fx1 (expt 2 fx2))) is a fixnum, then that fixnum is returned. Otherwise an exception with condition type &implementation-restriction is raised.

    (rnrs arithmetic fixnums (6)) procedure (fxarithmetic-shift-left (fx1 fixnum?) (fx2 fixnum?) ) ⟹ fixnum?

    Fx2 must be non-negative, and less than (fixnum-width). The fxarithmetic-shift-left procedure behaves the same as fxarithmetic-shift

    (rnrs arithmetic fixnums (6)) procedure (fxarithmetic-shift-right (fx1 fixnum?) (fx2 fixnum?) ) ⟹ fixnum?

    Fx2 must be non-negative, and less than (fixnum-width). (fxarithmetic-shift-right fx1 fx2) behaves the same as (fxarithmetic-shift fx1 (fx- fx2)).

    (rnrs arithmetic fixnums (6)) procedure (fxrotate-bit-field (i fixnum?) (from fixnum?) (to fixnum?) (count fixnum?) ) ⟹ fixnum?

    Fx2, fx3, and fx4 must be non-negative and less than (fixnum-width). Fx2 must be less than or equal to fx3. Fx4 must be less than the difference between fx3 and fx2. The fxrotate-bit-field procedure returns the result of cyclically permuting in fx1 the bits at positions from fx2 (inclusive) to fx3 (exclusive) by fx4 bits towards the more significant bits.

    (rnrs arithmetic fixnums (6)) procedure (fxreverse-bit-field (fx1 fixnum?) (fx2 fixnum?) (fx3 fixnum?) ) ⟹ fixnum?

    Fx2 and fx3 must be non-negative and less than (fixnum-width). Moreover, fx2 must be less than or equal to fx3. The fxreverse-bit-field procedure returns the fixnum obtained from fx1 by reversing the order of the bits at positions from fx2 (inclusive) to fx3 (exclusive).

    library (rnrs arithmetic flonums (6))

    (rnrs arithmetic flonums (6)) procedure (flonum? obj ) ⟹ boolean?

    Returns #t if obj is a flonum, #f otherwise.

    (rnrs arithmetic flonums (6)) procedure (real->flonum (x real?) ) ⟹ flonum?

    Returns the best flonum representation of x. The value returned is a flonum that is numerically closest to the argument.

    Note: If flonums are represented in binary floating point, then implementations should break ties by preferring the floating-point representation whose least significant bit is zero.

    (rnrs arithmetic flonums (6)) procedure (fl=? (x flonum?) (y flonum?) (z flonum?) ... ) ⟹ boolean?

    The procedure returns #t if its arguments are equal, #f otherwise. The predicate must be transitive.

    (rnrs arithmetic flonums (6)) procedure (fl<? (x flonum?) (y flonum?) (z flonum?) ... ) ⟹ boolean?

    The procedure returns #t if its arguments are monotonically increasing, #f otherwise. The predicate must be transitive.

    (rnrs arithmetic flonums (6)) procedure (fl>? (x flonum?) (y flonum?) (z flonum?) ... ) ⟹ boolean?

    The procedure returns #t if its arguments are monotonically decreasing, #f otherwise. The predicate must be transitive.

    (rnrs arithmetic flonums (6)) procedure (fl<=? (x flonum?) (y flonum?) (z flonum?) ... ) ⟹ boolean?

    The procedure returns #t if its arguments are monotonically nondecreasing, #f otherwise. The predicate must be transitive.

    (rnrs arithmetic flonums (6)) procedure (fl>=? (x flonum?) (y flonum?) (z flonum?) ... ) ⟹ boolean?

    The procedure returns #t if its arguments are monotonically nonincreasing, #f otherwise. The predicate must be transitive.

    (rnrs arithmetic flonums (6)) procedure (flinteger? (x flonum?) ) ⟹ boolean?

    Test the number is an integer

    (rnrs arithmetic flonums (6)) procedure (flzero? (x flonum?) ) ⟹ boolean?

    Test the number is a zero

    (rnrs arithmetic flonums (6)) procedure (flpositive? (x flonum?) ) ⟹ boolean?

    Test the number is greater than zero

    (rnrs arithmetic flonums (6)) procedure (flnegative? (x flonum?) ) ⟹ boolean?

    Test the number is less than zero

    (rnrs arithmetic flonums (6)) procedure (flodd? (x flonum?) ) ⟹ boolean?

    Test the number is odd

    (rnrs arithmetic flonums (6)) procedure (fleven? (x flonum?) ) ⟹ boolean?

    Test the number is even

    (rnrs arithmetic flonums (6)) procedure (flfinite? (x flonum?) ) ⟹ boolean?

    Test the number is not infinite

    (rnrs arithmetic flonums (6)) procedure (flinfinite? (x flonum?) ) ⟹ boolean?

    Test the number is an infinity

    (rnrs arithmetic flonums (6)) procedure (flnan? (x flonum?) ) ⟹ boolean?

    Test the number is Not A Number

    (rnrs arithmetic flonums (6)) procedure (flmax (x flonum?) ... ) ⟹ flonum?

    The procedure returns the maximum of its arguments. It always returns a NaN when one or more of the arguments is a NaN.

    (rnrs arithmetic flonums (6)) procedure (flmin (x flonum?) ... ) ⟹ flonum?

    The procedure returns the minimum of its arguments. It always returns a NaN when one or more of the arguments is a NaN.

    (rnrs arithmetic flonums (6)) procedure (fl+ (x flonum?) ... ) ⟹ flonum?

    The procedure returns the flonum sum of its flonum arguments. In general, it should return the flonum that best approximates the mathematical sum. (For implementations that represent flonums using IEEE binary floating point, the meaning of "best" is defined by the IEEE standards.)

    (rnrs arithmetic flonums (6)) procedure (fl* (x flonum?) ... ) ⟹ flonum?

    The procedure returns the flonum product of its flonum arguments. In general, it should return the flonum that best approximates the mathematical product. (For implementations that represent flonums using IEEE binary floating point, the meaning of "best" is defined by the IEEE standards.)

    (rnrs arithmetic flonums (6)) procedure (fl- (x flonum?) ) ⟹ flonum?

    (rnrs arithmetic flonums (6)) procedure (fl- (x flonum?) (y flonum?) ... ) ⟹ flonum?

    With two or more arguments, the procedure returns the flonum difference of its flonum arguments, associating to the left. With one argument, however, it returns the additive flonum inverse of its argument. In general, it should return the flonum that best approximates the mathematical difference. (For implementations that represent flonums using IEEE binary floating point, the meaning of "best" is reasonably well-defined by the IEEE standards.)

    (rnrs arithmetic flonums (6)) procedure (fl/ (x flonum?) ) ⟹ flonum?

    (rnrs arithmetic flonums (6)) procedure (fl/ (x flonum?) (y flonum?) ... ) ⟹ flonum?

    With two or more arguments, the procedure returns the flonum quotient of its flonum arguments, associating to the left. With one argument, however, it returns the multiplicative flonum inverse of its argument. In general, it should return the flonum that best approximates the mathematical quotient. (For implementations that represent flonums using IEEE binary floating point, the meaning of "best" is reasonably well-defined by the IEEE standards.)

    (rnrs arithmetic flonums (6)) procedure (flabs (fl flonum?) ) ⟹ flonum?

    Returns the absolute value of fl.

    (rnrs arithmetic flonums (6)) procedure (fldiv (x1 flonum?) (x2 flonum?) ) ⟹ flonum?

    Implements number-theoretic integer division and returns the results of the corresponding mathematical operations specified in report section on "Integer division". For zero divisors, the procedure may return a NaN or some unspecified flonum.

    (rnrs arithmetic flonums (6)) procedure (fldiv0 (x1 flonum?) (x2 flonum?) ) ⟹ flonum?

    Implements number-theoretic integer division and returns the results of the corresponding mathematical operations specified in report section on "Integer division". For zero divisors, the procedure may return a NaN or some unspecified flonum.

    (rnrs arithmetic flonums (6)) procedure (fldiv-and-mod (x1 flonum?) (x2 flonum?) ) ⟹ (values flonum?flonum?)

    Implements number-theoretic integer division and returns the results of the corresponding mathematical operations specified in report section on "Integer division". For zero divisors, the procedure may return a NaN or some unspecified flonum.

    (rnrs arithmetic flonums (6)) procedure (fldiv0-and-mod0 (x1 flonum?) (x2 flonum?) ) ⟹ (values flonum?flonum?)

    Implements number-theoretic integer division and returns the results of the corresponding mathematical operations specified in report section on "Integer division". For zero divisors, the procedure may return a NaN or some unspecified flonum.

    (rnrs arithmetic flonums (6)) procedure (flmod (x1 flonum?) (x2 flonum?) ) ⟹ flonum?

    Implements number-theoretic integer division and returns the results of the corresponding mathematical operations specified in report section on "Integer division". For zero divisors, the procedure may return a NaN or some unspecified flonum.

    (rnrs arithmetic flonums (6)) procedure (flmod0 (x1 flonum?) (x2 flonum?) ) ⟹ flonum?

    Implements number-theoretic integer division and returns the results of the corresponding mathematical operations specified in report section on "Integer division". For zero divisors, the procedure may return a NaN or some unspecified flonum.

    (rnrs arithmetic flonums (6)) procedure (flnumerator (fl flonum?) ) ⟹ flonum?

    The procedure returns the numerator of fl as a flonum; the result is computed as if fl was represented as a fraction in lowest terms.

    (rnrs arithmetic flonums (6)) procedure (fldenominator (fl flonum?) ) ⟹ flonum?

    The procedure returns the denominator of fl as a flonum; the result is computed as if fl was represented as a fraction in lowest terms. The denominator is always positive. The denominator of 0.0 is defined to be 1.0.

    (rnrs arithmetic flonums (6)) procedure (flfloor (fl flonum?) ) ⟹ flonum?

    Returns the largest integral flonum not larger than fl. Returns an infinity when given an infinity as an argument, and a NaN when given a NaN.

    (rnrs arithmetic flonums (6)) procedure (flceiling (fl flonum?) ) ⟹ flonum?

    Returns the smallest integral flonum not smaller than fl. Returns an infinity when given an infinity as an argument, and a NaN when given a NaN.

    (rnrs arithmetic flonums (6)) procedure (flround (fl flonum?) ) ⟹ flonum?

    Returns the closest integral flonum to fl, rounding to even when fl represents a number halfway between two integers. Returns an infinity when given an infinity as an argument, and a NaN when given a NaN.

    (rnrs arithmetic flonums (6)) procedure (fltruncate (fl flonum?) ) ⟹ flonum?

    Returns the integral flonum closest to fl whose absolute value is not larger than the absolute value of fl. Returns an infinity when given an infinity as an argument, and a NaN when given a NaN.

    (rnrs arithmetic flonums (6)) procedure (flexp (fl flonum?) ) ⟹ flonum?

    (rnrs arithmetic flonums (6)) procedure (fllog (fl flonum?) ) ⟹ flonum?

    (rnrs arithmetic flonums (6)) procedure (fllog (fl flonum?) (base flonum?) ) ⟹ flonum?

    (rnrs arithmetic flonums (6)) procedure (flsin (x flonum?) ) ⟹ flonum?

    (rnrs arithmetic flonums (6)) procedure (flcos (x flonum?) ) ⟹ flonum?

    (rnrs arithmetic flonums (6)) procedure (fltan (x flonum?) ) ⟹ flonum?

    (rnrs arithmetic flonums (6)) procedure (flasin (x flonum?) ) ⟹ flonum?

    (rnrs arithmetic flonums (6)) procedure (flacos (x flonum?) ) ⟹ flonum?

    (rnrs arithmetic flonums (6)) procedure (flatan (x flonum?) ) ⟹ flonum?

    (rnrs arithmetic flonums (6)) procedure (flatan (y flonum?) (x flonum?) ) ⟹ flonum?

    These procedures compute the usual transcendental functions. The flexp procedure computes the base-e exponential of fl. The fllog procedure with a single argument computes the natural logarithm of fl (not the base ten logarithm); (fllog fl1 fl2) computes the base-fl2 logarithm of fl1. The flasin, flacos, and flatan procedures compute arcsine, arccosine, and arctangent, respectively. (flatan fl1 fl2) computes the arc tangent of fl1/fl2.

    See report section on "Transcendental functions" for the underlying mathematical operations. In the event that these operations do not yield a real result for the given arguments, the result may be a NaN, or may be some unspecified flonum.

    Implementations that use IEEE binary floating-point arithmetic should follow the relevant standards for these procedures.

    (rnrs arithmetic flonums (6)) procedure (flsqrt (fl flonum?) ) ⟹ flonum?

    Returns the principal square root of fl. For −0.0, flsqrt should return −0.0; for other negative arguments, the result may be a NaN or some unspecified flonum.

    (rnrs arithmetic flonums (6)) procedure (flexpt (base flonum?) (power flonum?) ) ⟹ flonum?

    Either base should be non-negative, or, if base is negative, power should be an integer object. The flexpt procedure returns base raised to the power power. If base is negative and power is not an integer object, the result may be a NaN, or may be some unspecified flonum. If base is zero, then the result is zero.

    &no-infinitiesrecord-type-descriptor?

    (rnrs arithmetic flonums (6)) procedure (make-no-infinities-violation obj ) ⟹ no-infinities-violation?

    (rnrs arithmetic flonums (6)) procedure (no-infinities-violation? obj ) ⟹ boolean?

    &no-nansrecord-type-descriptor?

    (rnrs arithmetic flonums (6)) procedure (make-no-nans-violation obj ) ⟹ no-nans-violation?

    (rnrs arithmetic flonums (6)) procedure (no-nans-violation? obj ) ⟹ boolean?

    These condition types could be defined by the following code:

    (define-condition-type &no-infinities

    &implementation-restriction

    make-no-infinities-violation

    no-infinities-violation?)

    (define-condition-type &no-nans

    &implementation-restriction

    make-no-nans-violation

    no-nans-violation?)

    These types describe that a program has executed an arithmetic operations that is specified to return an infinity or a NaN, respectively, on a Scheme implementation that is not able to represent the infinity or NaN. (See report section on "Representability of infinities and NaNs".)

    (rnrs arithmetic flonums (6)) procedure (fixnum->flonum (fx fixnum?) ) ⟹ flonum?

    Returns a flonum that is numerically closest to fx.

    library (rnrs bytevectors (6))

    (rnrs bytevectors (6)) syntax (endianness () ((_ endianness-symbol)) )

    The name of <endianness symbol> must be a symbol describing an endianness. An implementation must support at least the symbols big and little, but may support other endianness symbols. (endianness <endianness symbol>) evaluates to the symbol named <endianness symbol>. Whenever one of the procedures operating on bytevectors accepts an endianness as an argument, that argument must be one of these symbols. It is a syntax violation for <endianness symbol> to be anything other than an endianness symbol supported by the implementation.

    Note: Implementors should use widely accepted designations for endianness symbols other than big and little.

    Note: Only the name of <endianness symbol> is significant.

    (rnrs bytevectors (6)) procedure (native-endianness ) ⟹ symbol?

    Returns the endianness symbol associated implementation's preferred endianness (usually that of the underlying machine architecture). This may be any <endianness symbol>, including a symbol other than big and little.

    (rnrs bytevectors (6)) procedure (bytevector? obj ) ⟹ boolean?

    Returns #t if obj is a bytevector, otherwise returns #f.

    (rnrs bytevectors (6)) procedure (make-bytevector (k integer?) ) ⟹ bytevector?

    (rnrs bytevectors (6)) procedure (make-bytevector (k integer?) (byte integer?) ) ⟹ bytevector?

    Returns a newly allocated bytevector of k bytes. If the fill argument is missing, the initial contents of the returned bytevector are unspecified. If the fill argument is present, it must be an exact integer object in the interval {−128, ... 255} that specifies the initial value for the bytes of the bytevector: If fill is positive, it is interpreted as an octet; if it is negative, it is interpreted as a byte.

    (rnrs bytevectors (6)) procedure (bytevector-length (bytevector bytevector?) ) ⟹ integer?

    Returns, as an exact integer object, the number of bytes in bytevector.

    (rnrs bytevectors (6)) procedure (bytevector=? (bytevector1 bytevector?) (bytevector2 bytevector?) ) ⟹ boolean?

    Returns #t if bytevector1 and bytevector2 are equal - that is, if they have the same length and equal bytes at all valid indices. It returns #f otherwise.

    (rnrs bytevectors (6)) procedure (bytevector-fill! (bytevector bytevector?) (k integer?) ) ⟹ undefined

    The fill argument is as in the description of the make-bytevector procedure. The bytevector-fill! procedure stores fill in every element of bytevector and returns unspecified values. Analogous to vector-fill!.

    (rnrs bytevectors (6)) procedure (bytevector-copy! (source bytevector?) (source-start integer?) (target bytevector?) (target-start integer?) (k integer?) ) ⟹ undefined

    Source and target must be bytevectors. Source-start, target-start, and k must be non-negative exact integer objects that satisfy

    0 <= source-start <= source-start + k <= lsource

    0 <= target-start <= target-start + k <= ltarget

    where lsource is the length of source and ltarget is the length of target. The bytevector-copy! procedure copies the bytes from source at indices source-start, ..., source-start + k - 1 to consecutive indices in target starting at target-index. This must work even if the memory regions for the source and the target overlap, i.e., the bytes at the target location after the copy must be equal to the bytes at the source location before the copy. This returns unspecified values.

    (rnrs bytevectors (6)) procedure (bytevector-copy (bytevector bytevector?) ) ⟹ bytevector?

    Returns a newly allocated copy of bytevector.

    (rnrs bytevectors (6)) procedure (bytevector-u8-ref (bytevector bytevector?) (k integer?) ) ⟹ integer?

    K must be a valid index of bytevector. The bytevector-u8-ref procedure returns the byte at index k of bytevector, as an octet.

    (rnrs bytevectors (6)) procedure (bytevector-s8-ref (bytevector bytevector?) (k integer?) ) ⟹ integer?

    K must be a valid index of bytevector. The bytevector-s8-ref procedure returns the byte at index k of bytevector, as a (signed) byte.

    (rnrs bytevectors (6)) procedure (bytevector-u8-set! (bytevector bytevector?) (k integer?) (octet integer?) ) ⟹ undefined

    K must be a valid index of bytevector. The bytevector-u8-set! procedure stores octet in element k of bytevector.

    (rnrs bytevectors (6)) procedure (bytevector-s8-set! (bytevector bytevector?) (k integer?) (byte integer?) ) ⟹ undefined

    K must be a valid index of bytevector. The bytevector-s8-set! procedure stores the two's-complement representation of byte in element k of bytevector.

    (rnrs bytevectors (6)) procedure (bytevector->u8-list (bytevector bytevector?) ) ⟹ list?

    The bytevector->u8-list procedure returns a newly allocated list of the octets of bytevector in the same order.

    (rnrs bytevectors (6)) procedure (u8-list->bytevector (list list?) ) ⟹ bytevector?

    list ⟹ (list (octet integer?))

    List must be a list of octets. The u8-list->bytevector procedure returns a newly allocated bytevector whose elements are the elements of list list, in the same order. It is analogous to list->vector.

    (rnrs bytevectors (6)) procedure (bytevector-uint-ref (bytevector bytevector?) (k integer?) (endianness symbol?) (size integer?) ) ⟹ integer?

    The bytevector-uint-ref procedure retrieves the exact integer object corresponding to the unsigned representation of size size and specified by endianness at indices k, ..., k + size − 1.

    (rnrs bytevectors (6)) procedure (bytevector-sint-ref (bytevector bytevector?) (k integer?) (endianness symbol?) (size integer?) ) ⟹ integer?

    The bytevector-sint-ref procedure retrieves the exact integer object corresponding to the two's-complement representation of size size and specified by endianness at indices k, ..., k + size − 1.

    (rnrs bytevectors (6)) procedure (bytevector-uint-set! (bytevector bytevector?) (k integer?) (n integer?) (endianness symbol?) (size integer?) ) ⟹ undefined

    The bytevector-uint-set! procedure stores the unsigned representation of size size and specified by endianness into bytevector at indices k, ..., k + size − 1.

    (rnrs bytevectors (6)) procedure (bytevector-sint-set! (bytevector bytevector?) (k integer?) (n integer?) (endianness symbol?) (size integer?) ) ⟹ undefined

    bytevector-sint-set! stores the two's-complement representation of size size and specified by endianness into bytevector at indices k, ..., k + size − 1.

    (rnrs bytevectors (6)) procedure (bytevector->uint-list (bytevector bytevector?) (endianness symbol?) (size integer?) ) ⟹ list?

    (rnrs bytevectors (6)) procedure (bytevector->sint-list (bytevector bytevector?) (endianness symbol?) (size integer?) ) ⟹ list?

    (rnrs bytevectors (6)) procedure (uint-list->bytevector (list list?) (endianness symbol?) (size integer?) ) ⟹ bytevector?

    (rnrs bytevectors (6)) procedure (sint-list->bytevector (list list?) (endianness symbol?) (size integer?) ) ⟹ bytevector?

    Size must be a positive exact integer object. For uint-list->bytevector, list must be a list of exact integer objects in the interval {0, ..., 256^mathitsize−1}. For sint-list->bytevector, list must be a list of exact integer objects in the interval {−256^mathitsize/2, ..., 256^mathitsize/2−1}. The length of bytevector or, respectively, of list must be divisible by size.

    These procedures convert between lists of integer objects and their consecutive representations according to size and endianness in the bytevector objects in the same way as bytevector->u8-list and u8-list->bytevector do for one-byte representations.

    (rnrs bytevectors (6)) procedure (bytevector-u16-ref (bytevector bytevector?) (k integer?) (endianness symbol?) (size integer?) ) ⟹ integer?

    (rnrs bytevectors (6)) procedure (bytevector-s16-ref (bytevector bytevector?) (k integer?) (endianness symbol?) (size integer?) ) ⟹ integer?

    (rnrs bytevectors (6)) procedure (bytevector-u16-native-ref (bytevector bytevector?) (k integer?) (size integer?) ) ⟹ integer?

    (rnrs bytevectors (6)) procedure (bytevector-s16-native-ref (bytevector bytevector?) (k integer?) (size integer?) ) ⟹ integer?

    (rnrs bytevectors (6)) procedure (bytevector-u16-set! (bytevector bytevector?) (k integer?) (n integer?) (endianness symbol?) (size integer?) ) ⟹ undefined

    (rnrs bytevectors (6)) procedure (bytevector-s16-set! (bytevector bytevector?) (k integer?) (n integer?) (endianness symbol?) (size integer?) ) ⟹ undefined

    (rnrs bytevectors (6)) procedure (bytevector-u16-native-set! (bytevector bytevector?) (k integer?) (n integer?) (size integer?) ) ⟹ undefined

    (rnrs bytevectors (6)) procedure (bytevector-s16-native-set! (bytevector bytevector?) (k integer?) (n integer?) (size integer?) ) ⟹ undefined

    K must be a valid index of bytevector; so must k + 1. For bytevector-u16-set! and bytevector-u16-native-set!, n must be an exact integer object in the interval {0, ..., 2^16−1}. For bytevector-s16-set! and bytevector-s16-native-set!, n must be an exact integer object in the interval {−2^15, ..., 2^15−1}.

    These retrieve and set two-byte representations of numbers at indices k and k + 1, according to the endianness specified by endianness. The procedures with u16 in their names deal with the unsigned representation; those with s16 in their names deal with the two's-complement representation.

    The procedures with native in their names employ the native endianness, and work only at aligned indices: k must be a multiple of 2.

    The ...-set! procedures return unspecified values.

    (rnrs bytevectors (6)) procedure (bytevector-u32-ref (bytevector bytevector?) (k integer?) (endianness symbol?) (size integer?) ) ⟹ integer?

    (rnrs bytevectors (6)) procedure (bytevector-s32-ref (bytevector bytevector?) (k integer?) (endianness symbol?) (size integer?) ) ⟹ integer?

    (rnrs bytevectors (6)) procedure (bytevector-u32-native-ref (bytevector bytevector?) (k integer?) (size integer?) ) ⟹ integer?

    (rnrs bytevectors (6)) procedure (bytevector-s32-native-ref (bytevector bytevector?) (k integer?) (size integer?) ) ⟹ integer?

    (rnrs bytevectors (6)) procedure (bytevector-u32-set! (bytevector bytevector?) (k integer?) (n integer?) (endianness symbol?) (size integer?) ) ⟹ undefined

    (rnrs bytevectors (6)) procedure (bytevector-s32-set! (bytevector bytevector?) (k integer?) (n integer?) (endianness symbol?) (size integer?) ) ⟹ undefined

    (rnrs bytevectors (6)) procedure (bytevector-u32-native-set! (bytevector bytevector?) (k integer?) (n integer?) (size integer?) ) ⟹ undefined

    (rnrs bytevectors (6)) procedure (bytevector-s32-native-set! (bytevector bytevector?) (k integer?) (n integer?) (size integer?) ) ⟹ undefined

    K, ..., k + 3 must be valid indices of bytevector. For bytevector-u32-set! and bytevector-u32-native-set!, n must be an exact integer object in the interval {0, ..., 2^32−1}. For bytevector-s32-set! and bytevector-s32-native-set!, n must be an exact integer object in the interval {−2^31, ..., 2^32−1}.

    These retrieve and set four-byte representations of numbers at indices k, ..., k + 3, according to the endianness specified by endianness. The procedures with u32 in their names deal with the unsigned representation; those with s32 with the two's-complement representation.

    The procedures with native in their names employ the native endianness, and work only at aligned indices: k must be a multiple of 4.

    The ...-set! procedures return unspecified values.

    (rnrs bytevectors (6)) procedure (bytevector-u64-ref (bytevector bytevector?) (k integer?) (endianness symbol?) (size integer?) ) ⟹ integer?

    (rnrs bytevectors (6)) procedure (bytevector-s64-ref (bytevector bytevector?) (k integer?) (endianness symbol?) (size integer?) ) ⟹ integer?

    (rnrs bytevectors (6)) procedure (bytevector-u64-native-ref (bytevector bytevector?) (k integer?) (size integer?) ) ⟹ integer?

    (rnrs bytevectors (6)) procedure (bytevector-s64-native-ref (bytevector bytevector?) (k integer?) (size integer?) ) ⟹ integer?

    (rnrs bytevectors (6)) procedure (bytevector-u64-set! (bytevector bytevector?) (k integer?) (n integer?) (endianness symbol?) (size integer?) ) ⟹ undefined

    (rnrs bytevectors (6)) procedure (bytevector-s64-set! (bytevector bytevector?) (k integer?) (n integer?) (endianness symbol?) (size integer?) ) ⟹ undefined

    (rnrs bytevectors (6)) procedure (bytevector-u64-native-set! (bytevector bytevector?) (k integer?) (n integer?) (size integer?) ) ⟹ undefined

    (rnrs bytevectors (6)) procedure (bytevector-s64-native-set! (bytevector bytevector?) (k integer?) (n integer?) (size integer?) ) ⟹ undefined

    K, ..., k + 7 must be valid indices of bytevector. For bytevector-u64-set! and bytevector-u64-native-set!, n must be an exact integer object in the interval {0, ..., 2^64−1}. For bytevector-s64-set! and bytevector-s64-native-set!, n must be an exact integer object in the interval {−2^63, ..., 2^64−1}.

    These retrieve and set eight-byte representations of numbers at indices k, ..., k + 7, according to the endianness specified by endianness. The procedures with u64 in their names deal with the unsigned representation; those with s64 with the two's-complement representation.

    The procedures with native in their names employ the native endianness, and work only at aligned indices: k must be a multiple of 8.

    The ...-set! procedures return unspecified values.

    (rnrs bytevectors (6)) procedure (bytevector-ieee-single-ref (bytevector bytevector?) (k integer?) (endianness symbol?) (size integer?) ) ⟹ real?

    K, ..., k + 3 must be valid indices of bytevector. The procedure returns the inexact real number object that best represents the IEEE-754 single-precision number represented by the four bytes beginning at index k.

    (rnrs bytevectors (6)) procedure (bytevector-ieee-double-ref (bytevector bytevector?) (k integer?) (endianness symbol?) (size integer?) ) ⟹ real?

    K, ..., k + 7 must be valid indices of bytevector. The procedure returns the inexact real number object that best represents the IEEE-754 double-precision number represented by the eight bytes beginning at index k.

    (rnrs bytevectors (6)) procedure (bytevector-ieee-single-native-ref (bytevector bytevector?) (k integer?) (size integer?) ) ⟹ real?

    K, ..., k + 3 must be valid indices of bytevector. K must be a multiple of 4. The procedure returns the inexact real number object that best represents the IEEE-754 single-precision number represented by the four bytes beginning at index k.

    (rnrs bytevectors (6)) procedure (bytevector-ieee-double-native-ref (bytevector bytevector?) (k integer?) (size integer?) ) ⟹ real?

    K, ..., k + 7 must be valid indices of bytevector. K must be a multiple of 8. The procedure returns the inexact real number object that best represents the IEEE-754 double-precision number represented by the eight bytes beginning at index k.

    (rnrs bytevectors (6)) procedure (bytevector-ieee-single-set! (bytevector bytevector?) (k integer?) (x real?) (endianness symbol?) (size integer?) ) ⟹ undefined

    K, ..., k + 3 must be valid indices of bytevector. The procedure stores an IEEE-754 single-precision representation of x into elements k through k + 3 of bytevector, and returns unspecified values.

    (rnrs bytevectors (6)) procedure (bytevector-ieee-double-set! (bytevector bytevector?) (k integer?) (x real?) (endianness symbol?) (size integer?) ) ⟹ undefined

    K, ..., k + 7 must be valid indices of bytevector. The procedure stores an IEEE-754 double-precision representation of x into elements k through k + 7 of bytevector, and returns unspecified values.

    (rnrs bytevectors (6)) procedure (bytevector-ieee-single-native-set! (bytevector bytevector?) (k integer?) (x real?) (size integer?) ) ⟹ undefined

    K, ..., k + 3 must be valid indices of bytevector. K must be a multiple of 4. The procedure stores an IEEE-754 single-precision representation of x into elements k through k + 3 of bytevector, and returns unspecified values.

    (rnrs bytevectors (6)) procedure (bytevector-ieee-double-native-set! (bytevector bytevector?) (k integer?) (x real?) (size integer?) ) ⟹ undefined

    K, ..., k + 7 must be valid indices of bytevector. K must be a multiple of 8. The procedure stores an IEEE-754 double-precision representation of x into elements k through k + 7 of bytevector, and returns unspecified values.

    (rnrs bytevectors (6)) procedure (string->utf8 (string string?) ) ⟹ bytevector?

    Returns a newly allocated (unless empty) bytevector that contains the UTF-8 encoding of the given string.

    (rnrs bytevectors (6)) procedure (string->utf16 (string string?) ) ⟹ bytevector?

    (rnrs bytevectors (6)) procedure (string->utf16 (string string?) (endianness symbol?) ) ⟹ bytevector?

    If endianness is specified, it must be the symbol big or the symbol little. The string->utf16 procedure returns a newly allocated (unless empty) bytevector that contains the UTF-16BE or UTF-16LE encoding of the given string (with no byte-order mark). If endianness is not specified or is big, then UTF-16BE is used. If endianness is little, then UTF-16LE is used.

    (rnrs bytevectors (6)) procedure (string->utf32 (string string?) ) ⟹ bytevector?

    (rnrs bytevectors (6)) procedure (string->utf32 (string string?) (endianness symbol?) ) ⟹ bytevector?

    If endianness is specified, it must be the symbol big or the symbol little. The string->utf32 procedure returns a newly allocated (unless empty) bytevector that contains the UTF-32BE or UTF-32LE encoding of the given string (with no byte mark). If endianness is not specified or is big, then UTF-32BE is used. If endianness is little, then UTF-32LE is used.

    (rnrs bytevectors (6)) procedure (utf8->string (bytevector bytevector?) ) ⟹ string?

    Returns a newly allocated (unless empty) string whose character sequence is encoded by the given bytevector.

    (rnrs bytevectors (6)) procedure (utf16->string (bytevector bytevector?) (endianness symbol?) ) ⟹ string?

    (rnrs bytevectors (6)) procedure (utf16->string (bytevector bytevector?) (endianness symbol?) (endianness-mandatory? boolean?) ) ⟹ string?

    Endianness must be the symbol big or the symbol little. The utf16->string procedure returns a newly allocated (unless empty) string whose character sequence is encoded by the given bytevector. Bytevector is decoded according to UTF-16BE or UTF-16LE: If endianness-mandatory? is absent or #f, utf16->string determines the endianness according to a UTF-16 BOM at the beginning of bytevector if a BOM is present; in this case, the BOM is not decoded as a character. Also in this case, if no UTF-16 BOM is present, endianness specifies the endianness of the encoding. If endianness-mandatory? is a true value, endianness specifies the endianness of the encoding, and any UTF-16 BOM in the encoding is decoded as a regular character.

    Note: A UTF-16 BOM is either a sequence of bytes #xFE, #xFF specifying big and UTF-16BE, or #xFF, #xFE specifying little and UTF-16LE.

    (rnrs bytevectors (6)) procedure (utf32->string (bytevector bytevector?) (endianness symbol?) ) ⟹ string?

    (rnrs bytevectors (6)) procedure (utf32->string (bytevector bytevector?) (endianness symbol?) (endianness-mandatory? boolean?) ) ⟹ string?

    Endianness must be the symbol big or the symbol little. The utf32->string procedure returns a newly allocated (unless empty) string whose character sequence is encoded by the given bytevector. Bytevector is decoded according to UTF-32BE or UTF-32LE: If endianness-mandatory? is absent or #f, utf32->string determines the endianness according to a UTF-32 BOM at the beginning of bytevector if a BOM is present; in this case, the BOM is not decoded as a character. Also in this case, if no UTF-32 BOM is present, endianness specifies the endianness of the encoding. If endianness-mandatory? is a true value, endianness specifies the endianness of the encoding, and any UTF-32 BOM in the encoding is decoded as a regular character.

    Note: A UTF-32 BOM is either a sequence of bytes #x00, #x00, #xFE, #xFF specifying big and UTF-32BE, or #xFF, #xFE, #x00, #x00, specifying little and UTF-32LE.

    library (rnrs conditions (6))

    &conditionrecord-type-descriptor?

    Simple conditions are records of subtypes of the &condition record type. The &condition type has no fields and is neither sealed nor opaque.

    (rnrs conditions (6)) procedure (condition (condition1 condition?) ... ) ⟹ condition?

    The condition procedure returns a condition object with the components of the conditions as its components, in the same order, i.e., with the components of condition1 appearing first in the same order as in condition1, then with the components of condition2, and so on. The returned condition is compound if the total number of components is zero or greater than one. Otherwise, it may be compound or simple.

    (rnrs conditions (6)) procedure (simple-conditions (condition condition?) ) ⟹ list?

    The simple-conditions procedure returns a list of the components of condition, in the same order as they appeared in the construction of condition. The returned list is immutable. If the returned list is modified, the effect on condition is unspecified.

    Note: Because condition decomposes its arguments into simple conditions, simple-conditions always returns a “flattened” list of simple conditions.

    (rnrs conditions (6)) procedure (condition? obj ) ⟹ boolean?

    Returns #t if obj is a (simple or compound) condition, otherwise returns #f.

    (rnrs conditions (6)) procedure (condition-predicate (rtd record-type-descriptor?) ) ⟹ procedure?

    (return obj ) ⟹ boolean?

    Rtd must be a record-type descriptor of a subtype of &condition. The condition-predicate procedure returns a procedure that takes one argument. This procedure returns #t if its argument is a condition of the condition type represented by rtd, i.e., if it is either a simple condition of that record type (or one of its subtypes) or a compound conditition with such a simple condition as one of its components, and #f otherwise.

    (rnrs conditions (6)) procedure (condition-accessor (rtd record-type-descriptor?) (proc procedure?) ) ⟹ procedure?

    (proc record ) ⟹ *

    (return record ) ⟹ *

    Rtd must be a record-type descriptor of a subtype of &condition. Proc should accept one argument, a record of the record type of rtd. The condition-accessor procedure returns a procedure that accepts a single argument, which must be a condition of the type represented by rtd. This procedure extracts the first component of the condition of the type represented by rtd, and returns the result of applying proc to that component.

    (rnrs conditions (6)) syntax (define-condition-type () ((_ condition-type supertype constructor predicate field-spec1 ...)) )

    (field accessor)

    The define-condition-type form expands into a record-type definition for a record type <condition-type> (see section 6.2). The record type will be non-opaque, non-sealed, and its fields will be immutable. It will have <supertype> has its parent type. The remaining identifiers will be bound as follows:

  • <Constructor> is bound to a default constructor for the type (see section 6.3): It accepts one argument for each of the record type's complete set of fields (including parent types, with the fields of the parent coming before those of the extension in the arguments) and returns a condition object initialized to those arguments.
  • <Predicate> is bound to a predicate that identifies conditions of type <condition-type> or any of its subtypes.
  • Each <accessor> is bound to a procedure that extracts the corresponding field from a condition of type <condition-type>.
  • &messagerecord-type-descriptor?

    (rnrs conditions (6)) procedure (make-message-condition message ) ⟹ message-condition?

    (rnrs conditions (6)) procedure (message-condition? obj ) ⟹ boolean?

    (rnrs conditions (6)) procedure (condition-message (condition message-condition?) ) ⟹ *

    This condition type could be defined by

    (define-condition-type &message &condition

    make-message-condition message-condition?

    (message condition-message))

    It carries a message further describing the nature of the condition to humans.

    &warningrecord-type-descriptor?

    (rnrs conditions (6)) procedure (make-warning ) ⟹ warning?

    (rnrs conditions (6)) procedure (warning? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &warning &condition

    make-warning warning?)

    This type describes conditions that do not, in principle, prohibit immediate continued execution of the program, but may interfere with the program's execution later.

    &seriousrecord-type-descriptor?

    (rnrs conditions (6)) procedure (make-serious-condition ) ⟹ serious?

    (rnrs conditions (6)) procedure (serious-condition? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &serious &condition

    make-serious-condition serious-condition?)

    This type describes conditions serious enough that they cannot safely be ignored. This condition type is primarily intended as a supertype of other condition types.

    &errorrecord-type-descriptor?

    (rnrs conditions (6)) procedure (make-error ) ⟹ error?

    (rnrs conditions (6)) procedure (error? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &error &serious

    make-error error?)

    This type describes errors, typically caused by something that has gone wrong in the interaction of the program with the external world or the user.

    &violationrecord-type-descriptor?

    (rnrs conditions (6)) procedure (make-violation ) ⟹ violation?

    (rnrs conditions (6)) procedure (violation? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &violation &serious

    make-violation violation?)

    This type describes violations of the language standard or a library standard, typically caused by a programming error.

    &assertionrecord-type-descriptor?

    (rnrs conditions (6)) procedure (make-assertion-violation ) ⟹ assertion-violation?

    (rnrs conditions (6)) procedure (assertion-violation? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &assertion &violation

    make-assertion-violation assertion-violation?)

    This type describes an invalid call to a procedure, either passing an invalid number of arguments, or passing an argument of the wrong type.

    &irritantsrecord-type-descriptor?

    (rnrs conditions (6)) procedure (make-irritants-condition (irritants list?) ) ⟹ irritants-condition?

    (rnrs conditions (6)) procedure (irritants-condition? obj ) ⟹ boolean?

    (rnrs conditions (6)) procedure (condition-irritants (condition irritants-condition?) ) ⟹ list?

    This condition type could be defined by

    (define-condition-type &irritants &condition

    make-irritants-condition irritants-condition?

    (irritants condition-irritants))

    Irritants should be a list of objects. This condition provides additional information about a condition, typically the argument list of a procedure that detected an exception. Conditions of this type are created by the error and assertion-violation procedures of report section on "Errors and violations".

    &whorecord-type-descriptor?

    (rnrs conditions (6)) procedure (make-who-condition (who (or string?symbol?)) ) ⟹ who-condition?

    (rnrs conditions (6)) procedure (who-condition? obj ) ⟹ boolean?

    (rnrs conditions (6)) procedure (condition-who (condition who-condition?) ) ⟹ string? / symbol? /

    This condition type could be defined by

    (define-condition-type &who &condition

    make-who-condition who-condition?

    (who condition-who))

    Who should be a symbol or string identifying the entity reporting the exception. Conditions of this type are created by the error and assertion-violation procedures (report section on "Errors and violations"), and the syntax-violation procedure (section on "Syntax violations").

    &non-continuablerecord-type-descriptor?

    (rnrs conditions (6)) procedure (make-non-continuable-violation ) ⟹ non-continuable-violation?

    (rnrs conditions (6)) procedure (non-continuable-violation? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &non-continuable &violation

    make-non-continuable-violation

    non-continuable-violation?)

    This type indicates that an exception handler invoked via raise has returned.

    &implementation-restrictionrecord-type-descriptor?

    (rnrs conditions (6)) procedure (make-implementation-restriction-violation ) ⟹ implementation-restriction-violation?

    (rnrs conditions (6)) procedure (implementation-restriction-violation? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &implementation-restriction

    &violation

    make-implementation-restriction-violation

    implementation-restriction-violation?)

    This type describes a violation of an implementation restriction allowed by the specification, such as the absence of representations for NaNs and infinities. (See section 11.3.)

    &lexicalrecord-type-descriptor?

    (rnrs conditions (6)) procedure (make-lexical-violation ) ⟹ lexical-violation?

    (rnrs conditions (6)) procedure (lexical-violation? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &lexical &violation

    make-lexical-violation lexical-violation?)

    This type describes syntax violations at the level of the datum syntax.

    &syntaxrecord-type-descriptor?

    (rnrs conditions (6)) procedure (make-syntax-violation form subform ) ⟹ syntax-violation?

    (rnrs conditions (6)) procedure (syntax-violation? obj ) ⟹ boolean?

    (rnrs conditions (6)) procedure (syntax-violation-form (condition syntax-violation?) ) ⟹ *

    (rnrs conditions (6)) procedure (syntax-violation-subform (condition syntax-violation?) ) ⟹ *

    This condition type could be defined by

    (define-condition-type &syntax &violation

    make-syntax-violation syntax-violation?

    (form syntax-violation-form)

    (subform syntax-violation-subform))

    This type describes syntax violations. Form should be the erroneous syntax object or a datum representing the code of the erroneous form. Subform should be an optional syntax object or datum within the erroneous form that more precisely locates the violation. It can be #f to indicate the absence of more precise information.

    &undefinedrecord-type-descriptor?

    (rnrs conditions (6)) procedure (make-undefined-violation ) ⟹ undefined-violation?

    (rnrs conditions (6)) procedure (undefined-violation? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &undefined &violation

    make-undefined-violation undefined-violation?)

    This type describes unbound identifiers in the program.

    library (rnrs control (6))

    (rnrs control (6)) syntax (when () ((_ test expression1 expression2 ...)) )

    A when expression is evaluated by evaluating the <test> expression. If <test> evaluates to a true value, the remaining <expression>s are evaluated in order, and the results of the last <expression> are returned as the results of the entire when expression. Otherwise, the when expression returns unspecified values.

    The final <expression> is in tail context if the when form is itself in tail context.

    (rnrs control (6)) syntax (unless () ((_ test expression1 expression2 ...)) )

    An unless expression is evaluated by evaluating the <test> expression. If <test> evaluates to #f, the remaining <expression>s are evaluated in order, and the results of the last <expression> are returned as the results of the entire unless expression. Otherwise, the unless expression returns unspecified values.

    The final <expression> is in tail context if the unless form is itself in tail context.

    (rnrs control (6)) syntax (do () ((_ (variable-decl1 ...) (test expression ...) command ...)) )

    (variable init step) (variable init)

    The do expression is an iteration construct. It specifies a set of variables to be bound, how they are to be initialized at the start, and how they are to be updated on each iteration.

    A do expression is evaluated as follows: The <init> expressions are evaluated (in some unspecified order), the <variable>s are bound to fresh locations, the results of the <init> expressions are stored in the bindings of the <variable>s, and then the iteration phase begins.

    Each iteration begins by evaluating <test>; if the result is #f, then the <command>s are evaluated in order for effect, the <step> expressions are evaluated in some unspecified order, the <variable>s are bound to fresh locations holding the results, and the next iteration begins.

    If <test> evaluates to a true value, the <expression>s are evaluated from left to right and the values of the last <expression> are returned. If no <expression>s are present, then the do expression returns unspecified values.

    The regionof the binding of a <variable> consists of the entire do expression except for the <init>s.

    A <step> may be omitted, in which case the effect is the same as if (<variable> <init> <variable>) had been written instead of (<variable> <init>).

    If a do expression appears in a tail context, the <expression>s are a <tail sequence> in the sense of report section on “Tail calls and tail contexts”, i.e., the last <expression> is also in a tail context.

    (rnrs control (6)) syntax (case-lambda () ((_ clause ...) procedure?) )

    (formals body)

    (variable1 ...) variable (variable1 ... variable_n . variable_n+1)

    A case-lambda expression evaluates to a procedure. This procedure, when applied, tries to match its arguments to the <case-lambda clause>s in order. The arguments match a clause if one of the following conditions is fulfilled:

  • <Formals> has the form (<variable> ...) and the number of arguments is the same as the number of formal parameters in <formals>.
  • <Formals> has the form (<variable1> ...<variablen> . <variablen+1)> and the number of arguments is at least n.
  • <Formals> has the form <variable>.
  • For the first clause matched by the arguments, the variables of the <formals> are bound to fresh locations containing the argument values in the same arrangement as with lambda. The last expression of a <body> in a case-lambda expression is in tail context. If the arguments match none of the clauses, an exception with condition type &assertion is raised.

    library (rnrs enums (6))

    (rnrs enums (6)) procedure (make-enumeration (symbol-list list?) ) ⟹ enum-set

    Symbol-list must be a list of symbols. The make-enumeration procedure creates a new enumeration type whose universe consists of those symbols (in canonical order of their first appearance in the list) and returns that universe as an enumeration set whose universe is itself and whose enumeration type is the newly created enumeration type.

    (rnrs enums (6)) procedure (enum-set-universe (enum-set enum-set) ) ⟹ enum-set

    Returns the set of all symbols that comprise the universe of its argument, as an enumeration set.

    (rnrs enums (6)) procedure (enum-set-indexer (enum-set enum-set) ) ⟹ procedure?

    (return (el symbol?) ) ⟹ #f / integer? /

    Returns a unary procedure that, given a symbol that is in the universe of enum-set, returns its 0-origin index within the canonical ordering of the symbols in the universe; given a value not in the universe, the unary procedure returns #f.

    (rnrs enums (6)) procedure (enum-set-constructor (enum-set enum-set) ) ⟹ procedure?

    (rnrs enums (6)) procedure (enum-set-constructor (enum-set enum-set) ) ⟹ procedure?

    (return (elements list?) ) ⟹ enum-set

    Returns a unary procedure that, given a list of symbols that belong to the universe of enum-set, returns a subset of that universe that contains exactly the symbols in the list. The values in the list must all belong to the universe.

    (rnrs enums (6)) procedure (enum-set->list (enum-set enum-set) ) ⟹ list?

    Returns a list of the symbols that belong to its argument, in the canonical order of the universe of enum-set.

    (rnrs enums (6)) procedure (enum-set-member? (element symbol?) (enum-set enum-set) ) ⟹ boolean?

    The enum-set-member? procedure returns #t if its first argument is an element of its second argument, #f otherwise.

    (rnrs enums (6)) procedure (enum-set-subset? (set1 enum-set) (set2 enum-set) ) ⟹ boolean?

    The enum-set-subset? procedure returns #t if the universe of enum-set1 is a subset of the universe of enum-set2 (considered as sets of symbols) and every element of enum-set1 is a member of enum-set2. It returns #f otherwise.

    (rnrs enums (6)) procedure (enum-set=? (set1 enum-set) (set2 enum-set) ) ⟹ boolean?

    The enum-set=? procedure returns #t if enum-set1 is a subset of enum-set2 and vice versa, as determined by the enum-set-subset? procedure. This implies that the universes of the two sets are equal as sets of symbols, but does not imply that they are equal as enumeration types. Otherwise, #f is returned.

    (rnrs enums (6)) procedure (enum-set-union (set1 enum-set) (set2 enum-set) ) ⟹ enum-set

    The enum-set-union procedure returns the union of enum-set1 and enum-set2.

    (rnrs enums (6)) procedure (enum-set-intersection (set1 enum-set) (set2 enum-set) ) ⟹ enum-set

    The enum-set-intersection procedure returns the intersection of enum-set1 and enum-set2.

    (rnrs enums (6)) procedure (enum-set-difference (set1 enum-set) (set2 enum-set) ) ⟹ enum-set

    The enum-set-difference procedure returns the difference of enum-set1 and enum-set2.

    (rnrs enums (6)) procedure (enum-set-complement (set enum-set) ) ⟹ enum-set

    Returns enum-set's complement with respect to its universe.

    (rnrs enums (6)) procedure (enum-set-projection (set1 enum-set) (set2 enum-set) ) ⟹ enum-set

    Projects enum-set1 into the universe of enum-set2, dropping any elements of enum-set1 that do not belong to the universe of enum-set2. (If enum-set1 is a subset of the universe of its second, no elements are dropped, and the injection is returned.)

    (rnrs enums (6)) syntax (define-enumeration () ((_ type-name (symbol ...) constructor-syntax)) )

    The define-enumeration form defines an enumeration type and provides two macros for constructing its members and sets of its members. A define-enumeration form is a definition and can appear anywhere any other <definition> can appear. <Type-name> is an identifier that is bound as a syntactic keyword; <symbol> ... are the symbols that comprise the universe of the enumeration (in order). (<type-name> <symbol>) checks at macro-expansion time whether the name of <symbol> is in the universe associated with <type-name>. If it is, (<type-name> <symbol>) is equivalent to <symbol>. It is a syntax violation if it is not. <Constructor-syntax> is an identifier that is bound to a macro that, given any finite sequence of the symbols in the universe, possibly with duplicates, expands into an expression that evaluates to the enumeration set of those symbols. (<constructor-syntax> <symbol> ...) checks at macro-expansion time whether every <symbol> ... is in the universe associated with <type-name>. It is a syntax violation if one or more is not. Otherwise (<constructor-syntax> <symbol> ...) is equivalent to ((enum-set-constructor (<constructor-syntax>)) '(<symbol> ...)).

    library (rnrs eval (6))

    (rnrs eval (6)) procedure (environment (list1 list?) ... ) ⟹ environment

    This procedure returns a specifier for the environment that results by starting with an empty environment and then importing each list, considered as an import set, into it. (See section 5.6 for a description of import sets.) The bindings of the environment represented by the specifier are immutable, as is the environment itself.

    (rnrs eval (6)) procedure (eval expr-or-def (environment-specifier environment) ) ⟹ *

    If expr-or-def is an expression, it is evaluated in the specified environment and its values are returned. If it is a definition, the specified identifier(s) are defined in the specified environment, provided the environment is not immutable. Implementations may extend eval to allow other objects.

    library (rnrs exceptions (6))

    (rnrs exceptions (6)) procedure (with-exception-handler (handler procedure?) (thunk procedure?) ) ⟹ *

    (handler obj ) ⟹ *

    (thunk ) ⟹ *

    Handler must be a procedure and should accept one argument. Thunk must be a procedure that accepts zero arguments. The with-exception-handler procedure returns the results of invoking thunk. Handler is installed as the current exception handler for the dynamic extent (as determined by dynamic-wind) of the invocation of thunk.

    Implementation responsibilities: The implementation must check the restrictions on handler to the extent performed by applying it as described when it is called as a result of a call to raise or raise-continuable. An implementation may check whether handler is an appropriate argument before applying it.

    (rnrs exceptions (6)) syntax (guard (=> else ) ((_ (variable cond-clause1 cond-clause2 ...) body)) )

    (test expression1 ...) (test => expression) (else expression1 expression2 ...)

    Evaluating a guard form evaluates <body> with an exception handler that binds the raised object to <variable> and within the scope of that binding evaluates the clauses as if they were the clauses of a cond expression. That implicit cond expression is evaluated with the continuation and dynamic environment of the guard expression. If every <cond clause>'s <test> evaluates to #f and there is no else clause, then raise is re-invoked on the raised object within the dynamic environment of the original call to raise except that the current exception handler is that of the guard expression. The final expression in a <cond> clause is in a tail context if the guard expression itself is.

    (rnrs exceptions (6)) procedure (raise obj ) ⟹ undefined

    Raises a non-continuable exception by invoking the current exception handler on obj. The handler is called with a continuation whose dynamic environment is that of the call to raise, except that the current exception handler is the one that was in place when the handler being called was installed. When the handler returns, a non-continuable exception with condition type &non-continuable is raised in the same dynamic environment as the handler.

    (rnrs exceptions (6)) procedure (raise-continuable obj ) ⟹ undefined

    Raises a continuable exception by invoking the current exception handler on obj. The handler is called with a continuation that is equivalent to the continuation of the call to raise-continuable, with these two exceptions: (1) the current exception handler is the one that was in place when the handler being called was installed, and (2) if the handler being called returns, then it will again become the current exception handler. If the handler returns, the values it returns become the values returned by the call to raise-continuable.

    library (rnrs files (6))

    (rnrs files (6)) procedure (file-exists? (filename string?) ) ⟹ boolean?

    Filename must be a file name (see section 8.2.1). The file-exists? procedure returns #t if the named file exists at the time the procedure is called, #f otherwise.

    (rnrs files (6)) procedure (delete-file (filename string?) ) ⟹ undefined

    Filename must be a file name (see section 8.2.1). The delete-file procedure deletes the named file if it exists and can be deleted, and returns unspecified values. If the file does not exist or cannot be deleted, an exception with condition type &i/o-filename is raised.

    library (rnrs files (6))

    &i/orecord-type-descriptor?

    (rnrs files (6)) procedure (make-i/o-error ) ⟹ i/o-error?

    (rnrs files (6)) procedure (i/o-error? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &i/o &error

    make-i/o-error i/o-error?)

    This is a supertype for a set of more specific I/O errors.

    &i/o-readrecord-type-descriptor?

    (rnrs files (6)) procedure (make-i/o-read-error ) ⟹ i/o-read-error?

    (rnrs files (6)) procedure (i/o-read-error? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &i/o-read &i/o

    make-i/o-read-error i/o-read-error?)

    This condition type describes read errors that occurred during an I/O operation.

    &i/o-writerecord-type-descriptor?

    (rnrs files (6)) procedure (make-i/o-write-error ) ⟹ i/o-write-error?

    (rnrs files (6)) procedure (i/o-write-error? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &i/o-write &i/o

    make-i/o-write-error i/o-write-error?)

    This condition type describes write errors that occurred during an I/O operation.

    &i/o-invalid-positionrecord-type-descriptor?

    (rnrs files (6)) procedure (make-i/o-invalid-position-error position ) ⟹ i/o-invalid-position-error?

    (rnrs files (6)) procedure (i/o-invalid-position-error? obj ) ⟹ boolean?

    (rnrs files (6)) procedure (i/o-error-position (condition i/o-invalid-position-error?) ) ⟹ *

    This condition type could be defined by

    (define-condition-type &i/o-invalid-position &i/o

    make-i/o-invalid-position-error

    i/o-invalid-position-error?

    (position i/o-error-position))

    This condition type describes attempts to set the file position to an invalid position. Position should be the file position that the program intended to set. This condition describes a range error, but not an assertion violation.

    &i/o-filenamerecord-type-descriptor?

    (rnrs files (6)) procedure (make-i/o-filename-error filename ) ⟹ i/o-filename-error?

    (rnrs files (6)) procedure (i/o-filename-error? obj ) ⟹ boolean?

    (rnrs files (6)) procedure (i/o-error-filename (condition i/o-filename-error?) ) ⟹ *

    This condition type could be defined by

    (define-condition-type &i/o-filename &i/o

    make-i/o-filename-error i/o-filename-error?

    (filename i/o-error-filename))

    This condition type describes an I/O error that occurred during an operation on a named file. Filename should be the name of the file.

    &i/o-file-protectionrecord-type-descriptor?

    (rnrs files (6)) procedure (make-i/o-file-protection-error file ) ⟹ i/o-file-protection-error?

    (rnrs files (6)) procedure (i/o-file-protection-error? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &i/o-file-protection

    &i/o-filename

    make-i/o-file-protection-error

    i/o-file-protection-error?)

    A condition of this type specifies that an operation tried to operate on a named file with insufficient access rights.

    &i/o-file-is-read-onlyrecord-type-descriptor?

    (rnrs files (6)) procedure (make-i/o-file-is-read-only-error file ) ⟹ i/o-file-is-read-only-error?

    (rnrs files (6)) procedure (i/o-file-is-read-only-error? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &i/o-file-is-read-only

    &i/o-file-protection

    make-i/o-file-is-read-only-error

    i/o-file-is-read-only-error?)

    A condition of this type specifies that an operation tried to operate on a named read-only file under the assumption that it is writeable.

    &i/o-file-already-existsrecord-type-descriptor?

    (rnrs files (6)) procedure (make-i/o-file-already-exists-error file ) ⟹ i/o-file-already-exists-error?

    (rnrs files (6)) procedure (i/o-file-already-exists-error? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &i/o-file-already-exists

    &i/o-filename

    make-i/o-file-already-exists-error

    i/o-file-already-exists-error?)

    A condition of this type specifies that an operation tried to operate on an existing named file under the assumption that it did not exist.

    &i/o-file-does-not-existrecord-type-descriptor?

    (rnrs files (6)) procedure (make-i/o-file-does-not-exist-error file ) ⟹ i/o-file-does-not-exist-error?

    (rnrs files (6)) procedure (i/o-file-does-not-exist-error? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &i/o-file-does-not-exist

    &i/o-filename

    make-i/o-file-does-not-exist-error

    i/o-file-does-not-exist-error?)

    A condition of this type specifies that an operation tried to operate on an non-existent named file under the assumption that it existed.

    &i/o-portrecord-type-descriptor?

    (rnrs files (6)) procedure (make-i/o-port-error (port port?) ) ⟹ i/o-port-error?

    (rnrs files (6)) procedure (i/o-port-error? obj ) ⟹ boolean?

    (rnrs files (6)) procedure (i/o-error-port (condition i/o-port-error?) ) ⟹ port?

    This condition type could be defined by

    (define-condition-type &i/o-port &i/o

    make-i/o-port-error i/o-port-error?

    (port i/o-error-port))

    This condition type specifies the port with which an I/O error is associated. Port should be the port. Conditions raised by procedures accepting a port as an argument should include an &i/o-port-error condition.

    library (rnrs hashtables (6))

    (rnrs hashtables (6)) procedure (make-eq-hashtable ) ⟹ hashtable?

    (rnrs hashtables (6)) procedure (make-eq-hashtable (k integer?) ) ⟹ hashtable?

    Returns a newly allocated mutable hashtable that accepts arbitrary objects as keys, and compares those keys with eq?. If an argument is given, the initial capacity of the hashtable is set to approximately k elements.

    (rnrs hashtables (6)) procedure (make-eqv-hashtable ) ⟹ hashtable?

    (rnrs hashtables (6)) procedure (make-eqv-hashtable (k integer?) ) ⟹ hashtable?

    Returns a newly allocated mutable hashtable that accepts arbitrary objects as keys, and compares those keys with eqv?. If an argument is given, the initial capacity of the hashtable is set to approximately k elements.

    (rnrs hashtables (6)) procedure (make-hashtable (hash-function procedure?) (equiv procedure?) ) ⟹ hashtable?

    (rnrs hashtables (6)) procedure (make-hashtable (hash-function procedure?) (equiv procedure?) (k integer?) ) ⟹ hashtable?

    (hash-function key ) ⟹ integer?

    (equiv a b ) ⟹ boolean?

    Hash-function and equiv must be procedures. Hash-function should accept a key as an argument and should return a non-negative exact integer object. Equiv should accept two keys as arguments and return a single value. Neither procedure should mutate the hashtable returned by make-hashtable. The make-hashtable procedure returns a newly allocated mutable hashtable using hash-function as the hash function and equiv as the equivalence function used to compare keys. If a third argument is given, the initial capacity of the hashtable is set to approximately k elements. Both hash-function and equiv should behave like pure functions on the domain of keys. For example, the string-hash and string=? procedures are permissible only if all keys are strings and the contents of those strings are never changed so long as any of them continues to serve as a key in the hashtable. Furthermore, any pair of keys for which equiv returns true should be hashed to the same exact integer objects by hash-function.

    Implementation responsibilities: The implementation must check the restrictions on hash-function and equiv to the extent performed by applying them as described.

    Note: Hashtables are allowed to cache the results of calling the hash function and equivalence function, so programs cannot rely on the hash function being called for every lookup or update. Furthermore any hashtable operation may call the hash function more than once.

    (rnrs hashtables (6)) procedure (hashtable? obj ) ⟹ boolean?

    Returns #t if obj is a hashtable, #f otherwise.

    (rnrs hashtables (6)) procedure (hashtable-size (hashtable hashtable?) ) ⟹ integer?

    Returns the number of keys contained in hashtable as an exact integer object.

    (rnrs hashtables (6)) procedure (hashtable-ref (hashtable hashtable?) key default ) ⟹ *

    Returns the value in hashtable associated with key. If hashtable does not contain an association for key, default is returned.

    (rnrs hashtables (6)) procedure (hashtable-set! (hashtable hashtable?) key obj ) ⟹ undefined

    Changes hashtable to associate key with obj, adding a new association or replacing any existing association for key, and returns unspecified values.

    (rnrs hashtables (6)) procedure (hashtable-delete! (hashtable hashtable?) key ) ⟹ undefined

    Removes any association for key within hashtable and returns unspecified values.

    (rnrs hashtables (6)) procedure (hashtable-contains? (hashtable hashtable?) key ) ⟹ boolean?

    Returns #t if hashtable contains an association for key, #f otherwise.

    (rnrs hashtables (6)) procedure (hashtable-update! (hashtable hashtable?) key (proc procedure?) default ) ⟹ boolean?

    (proc value ) ⟹ *

    Proc should accept one argument, should return a single value, and should not mutate hashtable. The hashtable-update! procedure applies proc to the value in hashtable associated with key, or to default if hashtable does not contain an association for key. The hashtable is then changed to associate key with the value returned by proc.

    (rnrs hashtables (6)) procedure (hashtable-copy (hashtable hashtable?) ) ⟹ hashtable?

    (rnrs hashtables (6)) procedure (hashtable-copy (hashtable hashtable?) (mutable boolean?) ) ⟹ hashtable?

    Returns a copy of hashtable. If the mutable argument is provided and is true, the returned hashtable is mutable; otherwise it is immutable.

    (rnrs hashtables (6)) procedure (hashtable-clear! (hashtable hashtable?) ) ⟹ undefined

    (rnrs hashtables (6)) procedure (hashtable-clear! (hashtable hashtable?) (k integer?) ) ⟹ undefined

    Removes all associations from hashtable and returns unspecified values.

    (rnrs hashtables (6)) procedure (hashtable-keys (hashtable hashtable?) ) ⟹ vector?

    Returns a vector of all keys in hashtable. The order of the vector is unspecified.

    (rnrs hashtables (6)) procedure (hashtable-entries (hashtable hashtable?) ) ⟹ (values vector?vector?)

    Returns two values, a vector of the keys in hashtable, and a vector of the corresponding values.

    (rnrs hashtables (6)) procedure (hashtable-equivalence-function (hashtable hashtable?) ) ⟹ procedure?

    (return a b ) ⟹ boolean?

    Returns the equivalence function used by hashtable to compare keys. For hashtables created with make-eq-hashtable and make-eqv-hashtable, returns eq? and eqv? respectively.

    (rnrs hashtables (6)) procedure (hashtable-hash-function (hashtable hashtable?) ) ⟹ procedure?

    (return key ) ⟹ integer?

    Returns the hash function used by hashtable. For hashtables created by make-eq-hashtable or make-eqv-hashtable, #f is returned.

    (rnrs hashtables (6)) procedure (hashtable-mutable? (hashtable hashtable?) ) ⟹ boolean?

    Returns #t if hashtable is mutable, otherwise #f.

    (rnrs hashtables (6)) procedure (equal-hash obj ) ⟹ integer?

    Returns an integer hash value for obj, based on its structure and current contents. This hash function is suitable for use with equal? as an equivalence function.

    Note: Like equal?, the equal-hash procedure must always terminate, even if its arguments contain cycles.

    (rnrs hashtables (6)) procedure (string-hash (string string?) ) ⟹ integer?

    Returns an integer hash value for string, based on its current contents. This hash function is suitable for use with string=? as an equivalence function.

    (rnrs hashtables (6)) procedure (string-ci-hash (string string?) ) ⟹ integer?

    Returns an integer hash value for string based on its current contents, ignoring case. This hash function is suitable for use with string-ci=? as an equivalence function.

    (rnrs hashtables (6)) procedure (symbol-hash (symbol symbol?) ) ⟹ integer?

    Returns an integer hash value for symbol.

    library (rnrs io ports (6))

    (rnrs io ports (6)) syntax (file-options () ((_ file-options-symbol ...) file-options) )

    Each <file-options symbol> must be a symbol. The file-options syntax returns a file-options object that encapsulates the specified options.

    When supplied to an operation that opens a file for output, the file-options object returned by (file-options) specifies that the file is created if it does not exist and an exception with condition type &i/o-file-already-exists is raised if it does exist. The following standard options can be included to modify the default behavior.

    no-create: If the file does not already exist, it is not created; instead, an exception with condition type &i/o-file-does-not-exist is raised. If the file already exists, the exception with condition type &i/o-file-already-exists is not raised and the file is truncated to zero length.

    no-fail: If the file already exists, the exception with condition type &i/o-file-already-exists is not raised, even if no-create is not included, and the file is truncated to zero length.

    no-truncate: If the file already exists and the exception with condition type &i/o-file-already-exists has been inhibited by inclusion of no-create or no-fail, the file is not truncated, but the port's current position is still set to the beginning of the file.

    These options have no effect when a file is opened only for input. Symbols other than those listed above may be used as <file-options symbol>s; they have implementation-specific meaning, if any.

    (rnrs io ports (6)) syntax (buffer-mode () ((_ buffer-mode-symbol) buffer-mode?) )

    <Buffer-mode symbol> must be a symbol whose name is one of none, line, and block. The result is the corresponding symbol, and specifies the associated buffer mode.

    (rnrs io ports (6)) procedure (buffer-mode? obj ) ⟹ boolean?

    Returns #t if the argument is a valid buffer-mode symbol, and returns #f otherwise.

    (rnrs io ports (6)) procedure (latin-1-codec ) ⟹ codec

    (rnrs io ports (6)) procedure (utf-8-codec ) ⟹ codec

    (rnrs io ports (6)) procedure (utf-16-codec ) ⟹ codec

    These are predefined codecs for the ISO 8859-1, UTF-8, and UTF-16 encoding schemes.

    A call to any of these procedures returns a value that is equal in the sense of eqv? to the result of any other call to the same procedure.

    (rnrs io ports (6)) syntax (eol-style () ((_ eol-style-symbol) symbol?) )

    <Eol-style symbol> should be a symbol whose name is one of lf, cr, crlf, nel, crnel, ls, and none. The form evaluates to the corresponding symbol. If the name of eol-style symbol is not one of these symbols, the effect and result are implementation-dependent; in particular, the result may be an eol-style symbol acceptable as an eol-style argument to make-transcoder. Otherwise, an exception is raised. For a textual port with a transcoder, and whose transcoder has an eol-style symbol none, no conversion occurs. For a textual input port, any eol-style symbol other than none means that all of the above line-ending encodings are recognized and are translated into a single linefeed. For a textual output port, none and lf are equivalent. Linefeed characters are encoded according to the specified eol-style symbol, and all other characters that participate in possible line endings are encoded as is.

    (rnrs io ports (6)) procedure (native-eol-style ) ⟹ symbol?

    Returns the default end-of-line style of the underlying platform, e.g., lf on Unix and crlf on Windows.

    &i/o-decodingrecord-type-descriptor?

    (rnrs io ports (6)) procedure (make-i/o-decoding-error (port port?) ) ⟹ i/o-decoding-error?

    (rnrs io ports (6)) procedure (i/o-decoding-error? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &i/o-decoding &i/o-port

    make-i/o-decoding-error i/o-decoding-error?)

    An exception with this type is raised when one of the operations for textual input from a port encounters a sequence of bytes that cannot be translated into a character or string by the input direction of the port's transcoder. When such an exception is raised, the port's position is past the invalid encoding.

    &i/o-encodingrecord-type-descriptor?

    (rnrs io ports (6)) procedure (make-i/o-encoding-error (port port?) (char char?) ) ⟹ i/o-encoding-error?

    (rnrs io ports (6)) procedure (i/o-encoding-error? obj ) ⟹ boolean?

    (rnrs io ports (6)) procedure (i/o-encoding-error-char (condition i/o-encoding-error?) ) ⟹ char?

    This condition type could be defined by

    (define-condition-type &i/o-encoding &i/o-port

    make-i/o-encoding-error i/o-encoding-error?

    (char i/o-encoding-error-char))

    An exception with this type is raised when one of the operations for textual output to a port encounters a character that cannot be translated into bytes by the output direction of the port's transcoder. Char is the character that could not be encoded.

    (rnrs io ports (6)) syntax (error-handling-mode () ((_ error-handling-mode-symbol) symbol?) )

    <Error-handling-mode symbol> should be a symbol whose name is one of ignore, raise, and replace. The form evaluates to the corresponding symbol. If error-handling-mode symbol is not one of these identifiers, effect and result are implementation-dependent: The result may be an error-handling-mode symbol acceptable as a handling-mode argument to make-transcoder. If it is not acceptable as a handling-mode argument to make-transcoder, an exception is raised.

    The error-handling mode of a transcoder specifies the behavior of textual I/O operations in the presence of encoding or decoding errors.

    If a textual input operation encounters an invalid or incomplete character encoding, and the error-handling mode is ignore, an appropriate number of bytes of the invalid encoding are ignored and decoding continues with the following bytes. If the error-handling mode is replace, the replacement character U+FFFD is injected into the data stream, an appropriate number of bytes are ignored, and decoding continues with the following bytes. If the error-handling mode is raise, an exception with condition type &i/o-decoding is raised.

    If a textual output operation encounters a character it cannot encode, and the error-handling mode is ignore, the character is ignored and encoding continues with the next character. If the error-handling mode is replace, a codec-specific replacement character is emitted by the transcoder, and encoding continues with the next character. The replacement character is U+FFFD for transcoders whose codec is one of the Unicode encodings, but is the ? character for the Latin-1 encoding. If the error-handling mode is raise, an exception with condition type &i/o-encoding is raised.

    (rnrs io ports (6)) procedure (make-transcoder (codec codec) ) ⟹ transcoder

    (rnrs io ports (6)) procedure (make-transcoder (codec codec) (eol-style symbol?) ) ⟹ transcoder

    (rnrs io ports (6)) procedure (make-transcoder (codec codec) (eol-style symbol?) (handling-mode symbol?) ) ⟹ transcoder

    Codec must be a codec; eol-style, if present, an eol-style symbol; and handling-mode, if present, an error-handling-mode symbol. Eol-style may be omitted, in which case it defaults to the native end-of-line style of the underlying platform. Handling-mode may be omitted, in which case it defaults to replace. The result is a transcoder with the behavior specified by its arguments.

    (rnrs io ports (6)) procedure (native-transcoder ) ⟹ transcoder

    Returns an implementation-dependent transcoder that represents a possibly locale-dependent "native" transcoding.

    (rnrs io ports (6)) procedure (transcoder-codec (transcoder transcoder) ) ⟹ codec

    (rnrs io ports (6)) procedure (transcoder-eol-style (transcoder transcoder) ) ⟹ symbol?

    (rnrs io ports (6)) procedure (transcoder-error-handling-mode (transcoder transcoder) ) ⟹ symbol?

    These are accessors for transcoder objects; when applied to a transcoder returned by make-transcoder, they return the codec, eol-style, and handling-mode arguments, respectively

    (rnrs io ports (6)) procedure (bytevector->string (bytevector bytevector?) (transcoder transcoder) ) ⟹ string?

    Returns the string that results from transcoding the bytevector according to the input direction of the transcoder.

    (rnrs io ports (6)) procedure (string->bytevector (string string?) (transcoder transcoder) ) ⟹ bytevector?

    Returns the bytevector that results from transcoding the string according to the output direction of the transcoder.

    (rnrs io ports (6)) procedure (eof-object ) ⟹ eof-object?

    Returns the end-of-file object.

    (rnrs io ports (6)) procedure (eof-object? obj ) ⟹ boolean?

    Returns #t if obj is the end-of-file object, #f otherwise.

    (rnrs io ports (6)) procedure (port? obj ) ⟹ boolean?

    Returns #t if the argument is a port, and returns #f otherwise.

    (rnrs io ports (6)) procedure (port-transcoder (port port?) ) ⟹ transcoder

    Returns the transcoder associated with port if port is textual and has an associated transcoder, and returns #f if port is binary or does not have an associated transcoder.

    (rnrs io ports (6)) procedure (textual-port? obj ) ⟹ boolean?

    The textual-port? procedure returns #t if port is textual, and returns #f otherwise.

    (rnrs io ports (6)) procedure (binary-port? obj ) ⟹ boolean?

    The binary-port? procedure returns #t if port is binary, and returns #f otherwise.

    (rnrs io ports (6)) procedure (transcoded-port (port binary-port?) (transcoder transcoder) ) ⟹ textual-port?

    The transcoded-port procedure returns a new textual port with the specified transcoder. Otherwise the new textual port's state is largely the same as that of binary-port. If binary-port is an input port, the new textual port will be an input port and will transcode the bytes that have not yet been read from binary-port. If binary-port is an output port, the new textual port will be an output port and will transcode output characters into bytes that are written to the byte sink represented by binary-port.

    As a side effect, however, transcoded-port closes binary-port in a special way that allows the new textual port to continue to use the byte source or sink represented by binary-port, even though binary-port itself is closed and cannot be used by the input and output operations described in this chapter.

    (rnrs io ports (6)) procedure (port-has-port-position? (port port?) ) ⟹ boolean?

    (rnrs io ports (6)) procedure (port-position (port binary-port?) ) ⟹ integer?

    (rnrs io ports (6)) procedure (port-position (port textual-port?) ) ⟹ opaque-port-position

    The port-has-port-position? procedure returns #t if the port supports the port-position operation, and #f otherwise.

    For a binary port, the port-position procedure returns the index of the position at which the next byte would be read from or written to the port as an exact non-negative integer object. For a textual port, port-position returns a value of some implementation-dependent type representing the port's position; this value may be useful only as the pos argument to set-port-position!, if the latter is supported on the port (see below).

    If the port does not support the operation, port-position raises an exception with condition type &assertion.

    (rnrs io ports (6)) procedure (port-has-set-port-position!? (port port?) ) ⟹ boolean?

    (rnrs io ports (6)) procedure (set-port-position! (port binary-port?) (pos integer?) ) ⟹ undefined

    (rnrs io ports (6)) procedure (set-port-position! (port textual-port?) (pos opaque-port-position) ) ⟹ undefined

    If port is a binary port, pos should be a non-negative exact integer object. If port is a textual port, pos should be the return value of a call to port-position on port.

    The port-has-set-port-position!? procedure returns #t if the port supports the set-port-position! operation, and #f otherwise.

    The set-port-position! procedure raises an exception with condition type &assertion if the port does not support the operation, and an exception with condition type &i/o-invalid-position if pos is not in the range of valid positions of port. Otherwise, it sets the current position of the port to pos. If port is an output port, set-port-position! first flushes port. (See flush-output-port, section 8.2.10.)

    If port is a binary output port and the current position is set beyond the current end of the data in the underlying data sink, the object is not extended until new data is written at that position. The contents of any intervening positions are unspecified. Binary ports created by open-file-output-port and open-file-input/output-port can always be extended in this manner within the limits of the underlying operating system. In other cases, attempts to set the port beyond the current end of data in the underlying object may result in an exception with condition type &i/o-invalid-position.

    (rnrs io ports (6)) procedure (close-port (port port?) ) ⟹ undefined

    Closes the port, rendering the port incapable of delivering or accepting data. If port is an output port, it is flushed before being closed. This has no effect if the port has already been closed. A closed port is still a port. The close-port procedure returns unspecified values.

    (rnrs io ports (6)) procedure (call-with-port (port port?) (proc procedure?) ) ⟹ *

    (proc (port port?) ) ⟹ *

    Proc must accept one argument. The call-with-port procedure calls proc with port as an argument. If proc returns, port is closed automatically and the values returned by proc are returned. If proc does not return, port is not closed automatically, except perhaps when it is possible to prove that port will never again be used for an input or output operation

    (rnrs io ports (6)) procedure (input-port? obj ) ⟹ boolean?

    Returns #t if the argument is an input port (or a combined input and output port), and returns #f otherwise.

    (rnrs io ports (6)) procedure (port-eof? (port input-port?) ) ⟹ boolean?

    Returns #t if the lookahead-u8 procedure (if input-port is a binary port) or the lookahead-char procedure (if input-port is a textual port) would return the end-of-file object, and #f otherwise. The operation may block indefinitely if no data is available but the port cannot be determined to be at end of file.

    (rnrs io ports (6)) procedure (open-file-input-port (string string?) ) ⟹ input-port?

    (rnrs io ports (6)) procedure (open-file-input-port (string string?) (options file-options) ) ⟹ input-port?

    (rnrs io ports (6)) procedure (open-file-input-port (string string?) (options file-options) (buffer-mode buffer-mode?) ) ⟹ input-port?

    (rnrs io ports (6)) procedure (open-file-input-port (string string?) (options file-options) (buffer-mode buffer-mode?) (transcoder (or #ftranscoder)) ) ⟹ input-port?

    Maybe-transcoder must be either a transcoder or #f.

    The open-file-input-port procedure returns an input port for the named file. The file-options and maybe-transcoder arguments are optional.

    The file-options argument, which may determine various aspects of the returned port (see section 8.2.2), defaults to the value of (file-options).

    The buffer-mode argument, if supplied, must be one of the symbols that name a buffer mode. The buffer-mode argument defaults to block.

    If maybe-transcoder is a transcoder, it becomes the transcoder associated with the returned port.

    If maybe-transcoder is #f or absent, the port will be a binary port and will support the port-position and set-port-position! operations. Otherwise the port will be a textual port, and whether it supports the port-position and set-port-position! operations is implementation-dependent (and possibly transcoder-dependent).

    (rnrs io ports (6)) procedure (open-bytevector-input-port (bytevector bytevector?) ) ⟹ input-port?

    (rnrs io ports (6)) procedure (open-bytevector-input-port (bytevector bytevector?) (transcoder (or #ftranscoder)) ) ⟹ input-port?

    Maybe-transcoder must be either a transcoder or #f.

    The open-bytevector-input-port procedure returns an input port whose bytes are drawn from bytevector. If transcoder is specified, it becomes the transcoder associated with the returned port.

    If maybe-transcoder is #f or absent, the port will be a binary port and will support the port-position and set-port-position! operations. Otherwise the port will be a textual port, and whether it supports the port-position and set-port-position! operations will be implementation-dependent (and possibly transcoder-dependent).

    If bytevector is modified after open-bytevector-input-port has been called, the effect on the returned port is unspecified.

    (rnrs io ports (6)) procedure (open-string-input-port (string string?) ) ⟹ input-port?

    Returns a textual input port whose characters are drawn from string. The port may or may not have an associated transcoder; if it does, the transcoder is implementation-dependent. The port should support the port-position and set-port-position! operations. If string is modified after open-string-input-port has been called, the effect on the returned port is unspecified.

    (rnrs io ports (6)) procedure (standard-input-port ) ⟹ binary-port?

    Returns a fresh binary input port connected to standard input. Whether the port supports the port-position and set-port-position! operations is implementation-dependent.

    (rnrs io ports (6)) procedure (current-input-port ) ⟹ textual-port?

    This returns a default textual port for input. Normally, this default port is associated with standard input, but can be dynamically re-assigned using the with-input-from-file procedure from the (rnrs io simple (6)) library (see section 8.3). The port may or may not have an associated transcoder; if it does, the transcoder is implementation-dependent.

    (rnrs io ports (6)) procedure (make-custom-binary-input-port (id string?) (read! procedure?) (get-position (or #fprocedure?)) (set-position! (or #fprocedure?)) (close (or #fprocedure?)) ) ⟹ input-port?

    (read! (bytevector bytevector?) (start integer?) (count integer?) ) ⟹ integer?

    (get-position ) ⟹ integer?

    (set-position! (position integer?) ) ⟹ undefined

    (close ) ⟹ undefined

    Returns a newly created binary input port whose byte source is an arbitrary algorithm represented by the read! procedure. Id must be a string naming the new port, provided for informational purposes only. Read! must be a procedure and should behave as specified below; it will be called by operations that perform binary input.

    Each of the remaining arguments may be #f; if any of those arguments is not #f, it must be a procedure and should behave as specified below.

    (read! bytevector start count) Start will be a non-negative exact integer object, count will be a positive exact integer object, and bytevector will be a bytevector whose length is at least start + count. The read! procedure should obtain up to count bytes from the byte source, and should write those bytes into bytevector starting at index start. The read! procedure should return an exact integer object. This integer object should represent the number of bytes that it has read. To indicate an end of file, the read! procedure should write no bytes and return 0.

    (get-position) The get-position procedure (if supplied) should return an exact integer object representing the current position of the input port. If not supplied, the custom port will not support the port-position operation.

    (set-position! pos) Pos will be a non-negative exact integer object. The set-position! procedure (if supplied) should set the position of the input port to pos. If not supplied, the custom port will not support the set-port-position! operation.

    (close) The close procedure (if supplied) should perform any actions that are necessary when the input port is closed.

    (rnrs io ports (6)) procedure (make-custom-textual-input-port (id string?) (read! procedure?) (get-position (or #fprocedure?)) (set-position! (or #fprocedure?)) (close (or #fprocedure?)) ) ⟹ input-port?

    (read! (string string?) (start integer?) (count integer?) ) ⟹ integer?

    (get-position ) ⟹ opaque-port-position

    (set-position! (position opaque-port-position) ) ⟹ undefined

    (close ) ⟹ undefined

    Returns a newly created textual input port whose character source is an arbitrary algorithm represented by the read! procedure. Id must be a string naming the new port, provided for informational purposes only. Read! must be a procedure and should behave as specified below; it will be called by operations that perform textual input.

    Each of the remaining arguments may be #f; if any of those arguments is not #f, it must be a procedure and should behave as specified below.

    (read! string start count) Start will be a non-negative exact integer object, count will be a positive exact integer object, and string will be a string whose length is at least start + count. The read! procedure should obtain up to count characters from the character source, and should write those characters into string starting at index start. The read! procedure should return an exact integer object representing the number of characters that it has written. To indicate an end of file, the read! procedure should write no bytes and return 0.

    (get-position) The get-position procedure (if supplied) should return a single value. The return value should represent the current position of the input port. If not supplied, the custom port will not support the port-position operation.

    (set-position! pos) The set-position! procedure (if supplied) should set the position of the input port to pos if pos is the return value of a call to get-position. If not supplied, the custom port will not support the set-port-position! operation.

    (close) The close procedure (if supplied) should perform any actions that are necessary when the input port is closed.

    The port may or may not have an an associated transcoder; if it does, the transcoder is implementation-dependent.

    (rnrs io ports (6)) procedure (get-u8 (input-port input-port?) ) ⟹ eof-object? / integer? /

    Reads from binary-input-port, blocking as necessary, until a byte is available from binary-input-port or until an end of file is reached. If a byte becomes available, get-u8 returns the byte as an octet and updates binary-input-port to point just past that byte. If no input byte is seen before an end of file is reached, the end-of-file object is returned.

    (rnrs io ports (6)) procedure (lookahead-u8 (input-port input-port?) ) ⟹ eof-object? / integer? /

    The lookahead-u8 procedure is like get-u8, but it does not update binary-input-port to point past the byte.

    (rnrs io ports (6)) procedure (get-bytevector-n (input-port input-port?) (count integer?) ) ⟹ eof-object? / bytevector? /

    Count must be an exact, non-negative integer object representing the number of bytes to be read. The get-bytevector-n procedure reads from binary-input-port, blocking as necessary, until count bytes are available from binary-input-port or until an end of file is reached. If count bytes are available before an end of file, get-bytevector-n returns a bytevector of size count. If fewer bytes are available before an end of file, get-bytevector-n returns a bytevector containing those bytes. In either case, the input port is updated to point just past the bytes read. If an end of file is reached before any bytes are available, get-bytevector-n returns the end-of-file object.

    (rnrs io ports (6)) procedure (get-bytevector-n! (input-port input-port?) (bytevector bytevector?) (start integer?) (count integer?) ) ⟹ integer? / eof-object? /

    Count must be an exact, non-negative integer object, representing the number of bytes to be read. bytevector must be a bytevector with at least start + count elements.

    The get-bytevector-n! procedure reads from binary-input-port, blocking as necessary, until count bytes are available from binary-input-port or until an end of file is reached. If count bytes are available before an end of file, they are written into bytevector starting at index start, and the result is count. If fewer bytes are available before the next end of file, the available bytes are written into bytevector starting at index start, and the result is a number object representing the number of bytes actually read. In either case, the input port is updated to point just past the bytes read. If an end of file is reached before any bytes are available, get-bytevector-n! returns the end-of-file object.

    (rnrs io ports (6)) procedure (get-bytevector-some (input-port input-port?) ) ⟹ bytevector? / eof-object? /

    Reads from binary-input-port, blocking as necessary, until bytes are available from binary-input-port or until an end of file is reached. If bytes become available, get-bytevector-some returns a freshly allocated bytevector containing the initial available bytes (at least one), and it updates binary-input-port to point just past these bytes. If no input bytes are seen before an end of file is reached, the end-of-file object is returned.

    (rnrs io ports (6)) procedure (get-bytevector-all (input-port input-port?) ) ⟹ bytevector? / eof-object? /

    Attempts to read all bytes until the next end of file, blocking as necessary. If one or more bytes are read, get-bytevector-all returns a bytevector containing all bytes up to the next end of file. Otherwise, get-bytevector-all returns the end-of-file object. The operation may block indefinitely waiting to see if more bytes will become available, even if some bytes are already available.

    (rnrs io ports (6)) procedure (get-char (input-port input-port?) ) ⟹ eof-object? / char? /

    Reads from textual-input-port, blocking as necessary, until a complete character is available from textual-input-port, or until an end of file is reached.

    If a complete character is available before the next end of file, get-char returns that character and updates the input port to point past the character. If an end of file is reached before any character is read, get-char returns the end-of-file object.

    (rnrs io ports (6)) procedure (lookahead-char (input-port input-port?) ) ⟹ eof-object? / char? /

    The lookahead-char procedure is like get-char, but it does not update textual-input-port to point past the character.

    (rnrs io ports (6)) procedure (get-string-n (input-port input-port?) (count integer?) ) ⟹ eof-object? / string? /

    Count must be an exact, non-negative integer object, representing the number of characters to be read.

    The get-string-n procedure reads from textual-input-port, blocking as necessary, until count characters are available, or until an end of file is reached.

    If count characters are available before end of file, get-string-n returns a string consisting of those count characters. If fewer characters are available before an end of file, but one or more characters can be read, get-string-n returns a string containing those characters. In either case, the input port is updated to point just past the characters read. If no characters can be read before an end of file, the end-of-file object is returned.

    (rnrs io ports (6)) procedure (get-string-n! (input-port input-port?) (string string?) (start integer?) (count integer?) ) ⟹ eof-object? / integer? /

    Start and count must be exact, non-negative integer objects, with count representing the number of characters to be read. String must be a string with at least start + count characters.

    The get-string-n! procedure reads from textual-input-port in the same manner as get-string-n. If count characters are available before an end of file, they are written into string starting at index start, and count is returned. If fewer characters are available before an end of file, but one or more can be read, those characters are written into string starting at index start and the number of characters actually read is returned as an exact integer object. If no characters can be read before an end of file, the end-of-file object is returned.

    (rnrs io ports (6)) procedure (get-string-all (input-port input-port?) ) ⟹ eof-object? / string? /

    Reads from textual-input-port until an end of file, decoding characters in the same manner as get-string-n and get-string-n!. If characters are available before the end of file, a string containing all the characters decoded from that data are returned. If no character precedes the end of file, the end-of-file object is returned.

    (rnrs io ports (6)) procedure (get-line (input-port input-port?) ) ⟹ eof-object? / string? /

    Reads from textual-input-port up to and including the linefeed character or end of file, decoding characters in the same manner as get-string-n and get-string-n!.

    If a linefeed character is read, a string containing all of the text up to (but not including) the linefeed character is returned, and the port is updated to point just past the linefeed character. If an end of file is encountered before any linefeed character is read, but some characters have been read and decoded as characters, a string containing those characters is returned. If an end of file is encountered before any characters are read, the end-of-file object is returned.

    (rnrs io ports (6)) procedure (get-datum (input-port input-port?) ) ⟹ *

    Reads an external representation from textual-input-port and returns the datum it represents. The get-datum procedure returns the next datum that can be parsed from the given textual-input-port, updating textual-input-port to point exactly past the end of the external representation of the object.

    Any <interlexeme space> (see report section on “Lexical syntax”) in the input is first skipped. If an end of file occurs after the <interlexeme space>, the end-of-file object (see section 8.2.5) is returned.

    If a character inconsistent with an external representation is encountered in the input, an exception with condition types &lexical and &i/o-read is raised. Also, if the end of file is encountered after the beginning of an external representation, but the external representation is incomplete and therefore cannot be parsed, an exception with condition types &lexical and &i/o-read is raised.

    (rnrs io ports (6)) procedure (output-port? obj ) ⟹ boolean?

    Returns #t if the argument is an output port (or a combined input and output port), #f otherwise.

    (rnrs io ports (6)) procedure (flush-output-port (port output-port?) ) ⟹ undefined

    Flushes any buffered output from the buffer of output-port to the underlying file, device, or object. The flush-output-port procedure returns unspecified values.

    (rnrs io ports (6)) procedure (output-port-buffer-mode (port output-port?) ) ⟹ buffer-mode?

    Returns the symbol that represents the buffer mode of output-port.

    (rnrs io ports (6)) procedure (open-file-output-port (filename string?) ) ⟹ output-port?

    (rnrs io ports (6)) procedure (open-file-output-port (filename string?) (file-options file-options) ) ⟹ output-port?

    (rnrs io ports (6)) procedure (open-file-output-port (filename string?) (file-options file-options) (buffer-mode buffer-mode?) ) ⟹ output-port?

    (rnrs io ports (6)) procedure (open-file-output-port (filename string?) (file-options file-options) (buffer-mode buffer-mode?) (maybe-transcoder (or transcoder#f)) ) ⟹ output-port?

    Maybe-transcoder must be either a transcoder or #f.

    The open-file-output-port procedure returns an output port for the named file.

    The file-options argument, which may determine various aspects of the returned port (see section 8.2.2), defaults to the value of (file-options).

    The buffer-mode argument, if supplied, must be one of the symbols that name a buffer mode. The buffer-mode argument defaults to block.

    If maybe-transcoder is a transcoder, it becomes the transcoder associated with the port.

    If maybe-transcoder is #f or absent, the port will be a binary port and will support the port-position and set-port-position! operations. Otherwise the port will be a textual port, and whether it supports the port-position and set-port-position! operations is implementation-dependent (and possibly transcoder-dependent).

    (rnrs io ports (6)) procedure (open-bytevector-output-port ) ⟹ (values output-port?procedure?)

    (rnrs io ports (6)) procedure (open-bytevector-output-port (maybe-transcoder (or #ftranscoder)) ) ⟹ (values output-port?procedure?)

    (return ) ⟹ bytevector?

    Maybe-transcoder must be either a transcoder or #f.

    The open-bytevector-output-port procedure returns two values: an output port and an extraction procedure. The output port accumulates the bytes written to it for later extraction by the procedure.

    If maybe-transcoder is a transcoder, it becomes the transcoder associated with the port. If maybe-transcoder is #f or absent, the port will be a binary port and will support the port-position and set-port-position! operations. Otherwise the port will be a textual port, and whether it supports the port-position and set-port-position! operations is implementation-dependent (and possibly transcoder-dependent).

    The extraction procedure takes no arguments. When called, it returns a bytevector consisting of all the port's accumulated bytes (regardless of the port's current position), removes the accumulated bytes from the port, and resets the port's position.

    (rnrs io ports (6)) procedure (call-with-bytevector-output-port (proc procedure?) ) ⟹ bytevector?

    (rnrs io ports (6)) procedure (call-with-bytevector-output-port (proc procedure?) (maybe-transcoder (or #ftranscoder)) ) ⟹ bytevector?

    (proc (port output-port?) ) ⟹ *

    Proc must accept one argument. Maybe-transcoder must be either a transcoder or #f.

    The call-with-bytevector-output-port procedure creates an output port that accumulates the bytes written to it and calls proc with that output port as an argument. Whenever proc returns, a bytevector consisting of all of the port's accumulated bytes (regardless of the port's current position) is returned and the port is closed.

    The transcoder associated with the output port is determined as for a call to open-bytevector-output-port.

    (rnrs io ports (6)) procedure (open-string-output-port ) ⟹ (values output-port?procedure?)

    (return ) ⟹ string?

    Returns two values: a textual output port and an extraction procedure. The output port accumulates the characters written to it for later extraction by the procedure.

    The port may or may not have an associated transcoder; if it does, the transcoder is implementation-dependent. The port should support the port-position and set-port-position! operations.

    The extraction procedure takes no arguments. When called, it returns a string consisting of all of the port's accumulated characters (regardless of the current position), removes the accumulated characters from the port, and resets the port's position.

    (rnrs io ports (6)) procedure (call-with-string-output-port (proc procedure?) ) ⟹ string?

    (proc (port output-port?) ) ⟹ *

    Proc must accept one argument. The call-with-string-output-port procedure creates a textual output port that accumulates the characters written to it and calls proc with that output port as an argument. Whenever proc returns, a string consisting of all of the port's accumulated characters (regardless of the port's current position) is returned and the port is closed.

    The port may or may not have an associated transcoder; if it does, the transcoder is implementation-dependent. The port should support the port-position and set-port-position! operations.

    (rnrs io ports (6)) procedure (standard-output-port ) ⟹ output-port?

    (rnrs io ports (6)) procedure (standard-error-port ) ⟹ output-port?

    Returns a fresh binary output port connected to the standard output or standard error respectively. Whether the port supports the port-position and set-port-position! operations is implementation-dependent.

    (rnrs io ports (6)) procedure (current-output-port ) ⟹ output-port?

    (rnrs io ports (6)) procedure (current-error-port ) ⟹ output-port?

    These return default textual ports for regular output and error output. Normally, these default ports are associated with standard output, and standard error, respectively. The return value of current-output-port can be dynamically re-assigned using the with-output-to-file procedure from the (rnrs io simple (6)) library (see section 8.3). A port returned by one of these procedures may or may not have an associated transcoder; if it does, the transcoder is implementation-dependent.

    (rnrs io ports (6)) procedure (make-custom-binary-output-port (id string?) (write! procedure?) (get-position (or #fprocedure?)) (set-position! (or #fprocedure?)) (close (or #fprocedure?)) ) ⟹ output-port?

    (write! (bytevector bytevector?) (start integer?) (count integer?) ) ⟹ integer?

    (get-position ) ⟹ integer?

    (set-position! (position integer?) ) ⟹ undefined

    (close ) ⟹ undefined

    Returns a newly created binary output port whose byte sink is an arbitrary algorithm represented by the write! procedure. Id must be a string naming the new port, provided for informational purposes only. Write! must be a procedure and should behave as specified below; it will be called by operations that perform binary output.

    Each of the remaining arguments may be #f; if any of those arguments is not #f, it must be a procedure and should behave as specified in the description of make-custom-binary-input-port.

    (write! bytevector start count) Start and count will be non-negative exact integer objects, and bytevector will be a bytevector whose length is at least start + count. The write! procedure should write up to count bytes from bytevector starting at index start to the byte sink. If count is 0, the write! procedure should have the effect of passing an end-of-file object to the byte sink. In any case, the write! procedure should return the number of bytes that it wrote, as an exact integer object.

    (rnrs io ports (6)) procedure (make-custom-textual-output-port (id string?) (write! procedure?) (get-position (or #fprocedure?)) (set-position! (or #fprocedure?)) (close (or #fprocedure?)) ) ⟹ output-port?

    (write! (string string?) (start integer?) (count integer?) ) ⟹ integer?

    (get-position ) ⟹ integer?

    (set-position! (position integer?) ) ⟹ undefined

    (close ) ⟹ undefined

    Returns a newly created textual output port whose byte sink is an arbitrary algorithm represented by the write! procedure. Id must be a string naming the new port, provided for informational purposes only. Write! must be a procedure and should behave as specified below; it will be called by operations that perform textual output.

    Each of the remaining arguments may be #f; if any of those arguments is not #f, it must be a procedure and should behave as specified in the description of make-custom-textual-input-port.

    (write! string start count) Start and count will be non-negative exact integer objects, and string will be a string whose length is at least start + count. The write! procedure should write up to count characters from string starting at index start to the character sink. If count is 0, the write! procedure should have the effect of passing an end-of-file object to the character sink. In any case, the write! procedure should return the number of characters that it wrote, as an exact integer object.

    The port may or may not have an associated transcoder; if it does, the transcoder is implementation-dependent.

    (rnrs io ports (6)) procedure (put-u8 (port output-port?) (octet integer?) ) ⟹ undefined

    Writes octet to the output port and returns unspecified values.

    (rnrs io ports (6)) procedure (put-bytevector (port output-port?) (bytevector bytevector?) ) ⟹ undefined

    (rnrs io ports (6)) procedure (put-bytevector (port output-port?) (bytevector bytevector?) (start integer?) ) ⟹ undefined

    (rnrs io ports (6)) procedure (put-bytevector (port output-port?) (bytevector bytevector?) (start integer?) (count integer?) ) ⟹ undefined

    Start and count must be non-negative exact integer objects that default to 0 and (bytevector-length bytevector) − start, respectively. Bytevector must have a length of at least start + count. The put-bytevector procedure writes the count bytes of the bytevector bytevector starting at index start to the output port. The put-bytevector procedure returns unspecified values.

    (rnrs io ports (6)) procedure (put-char (port output-port?) (char char?) ) ⟹ undefined

    Writes char to the port. The put-char procedure returns unspecified values.

    (rnrs io ports (6)) procedure (put-string (port output-port?) (string string?) ) ⟹ undefined

    (rnrs io ports (6)) procedure (put-string (port output-port?) (string string?) (start integer?) ) ⟹ undefined

    (rnrs io ports (6)) procedure (put-string (port output-port?) (string string?) (start integer?) (count integer?) ) ⟹ undefined

    Start and count must be non-negative exact integer objects. String must have a length of at least start + count. Start defaults to 0. Count defaults to (string-length string) − start. The put-string procedure writes the count characters of string starting at index start to the port. The put-string procedure returns unspecified values.

    (rnrs io ports (6)) procedure (put-datum (port output-port?) datum ) ⟹ undefined

    Datum should be a datum value. The put-datum procedure writes an external representation of datum to textual-output-port. The specific external representation is implementation-dependent. However, whenever possible, an implementation should produce a representation for which get-datum, when reading the representation, will return an object equal (in the sense of equal?) to datum.

    (rnrs io ports (6)) procedure (open-file-input/output-port (string string?) ) ⟹ port?

    (rnrs io ports (6)) procedure (open-file-input/output-port (string string?) (options file-options) ) ⟹ port?

    (rnrs io ports (6)) procedure (open-file-input/output-port (string string?) (options file-options) (buffer-mode buffer-mode?) ) ⟹ port?

    (rnrs io ports (6)) procedure (open-file-input/output-port (string string?) (options file-options) (buffer-mode buffer-mode?) (transcoder (or #ftranscoder)) ) ⟹ port?

    Returns a single port that is both an input port and an output port for the named file. The optional arguments default as described in the specification of open-file-output-port. If the input/output port supports port-position and/or set-port-position!, the same port position is used for both input and output.

    (rnrs io ports (6)) procedure (make-custom-binary-input/output-port (id string?) (read! procedure?) (write! procedure?) (get-position (or #fprocedure?)) (set-position! (or #fprocedure?)) (close (or #fprocedure?)) ) ⟹ port?

    (read! (bytevector bytevector?) (start integer?) (count integer?) ) ⟹ integer?

    (write! (bytevector bytevector?) (start integer?) (count integer?) ) ⟹ integer?

    (get-position ) ⟹ integer?

    (set-position! (position integer?) ) ⟹ undefined

    (close ) ⟹ undefined

    Returns a newly created binary input/output port whose byte source and sink are arbitrary algorithms represented by the read! and write! procedures. Id must be a string naming the new port, provided for informational purposes only. Read! and write! must be procedures, and should behave as specified for the make-custom-binary-input-port and make-custom-binary-output-port procedures.

    Each of the remaining arguments may be #f; if any of those arguments is not #f, it must be a procedure and should behave as specified in the description of make-custom-binary-input-port.

    (rnrs io ports (6)) procedure (make-custom-textual-input/output-port (id string?) (read! procedure?) (write! procedure?) (get-position (or #fprocedure?)) (set-position! (or #fprocedure?)) (close (or #fprocedure?)) ) ⟹ port?

    (read! (string string?) (start integer?) (count integer?) ) ⟹ integer?

    (write! (string string?) (start integer?) (count integer?) ) ⟹ integer?

    (get-position ) ⟹ opaque-port-position

    (set-position! (position opaque-port-position) ) ⟹ undefined

    (close ) ⟹ undefined

    Returns a newly created textual input/output port whose textual source and sink are arbitrary algorithms represented by the read! and write! procedures. Id must be a string naming the new port, provided for informational purposes only. Read! and write! must be procedures, and should behave as specified for the make-custom-textual-input-port and make-custom-textual-output-port procedures.

    Each of the remaining arguments may be #f; if any of those arguments is not #f, it must be a procedure and should behave as specified in the description of make-custom-textual-input-port.

    library (rnrs io ports (6))

    &i/orecord-type-descriptor?

    (rnrs io ports (6)) procedure (make-i/o-error ) ⟹ i/o-error?

    (rnrs io ports (6)) procedure (i/o-error? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &i/o &error

    make-i/o-error i/o-error?)

    This is a supertype for a set of more specific I/O errors.

    &i/o-readrecord-type-descriptor?

    (rnrs io ports (6)) procedure (make-i/o-read-error ) ⟹ i/o-read-error?

    (rnrs io ports (6)) procedure (i/o-read-error? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &i/o-read &i/o

    make-i/o-read-error i/o-read-error?)

    This condition type describes read errors that occurred during an I/O operation.

    &i/o-writerecord-type-descriptor?

    (rnrs io ports (6)) procedure (make-i/o-write-error ) ⟹ i/o-write-error?

    (rnrs io ports (6)) procedure (i/o-write-error? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &i/o-write &i/o

    make-i/o-write-error i/o-write-error?)

    This condition type describes write errors that occurred during an I/O operation.

    &i/o-invalid-positionrecord-type-descriptor?

    (rnrs io ports (6)) procedure (make-i/o-invalid-position-error position ) ⟹ i/o-invalid-position-error?

    (rnrs io ports (6)) procedure (i/o-invalid-position-error? obj ) ⟹ boolean?

    (rnrs io ports (6)) procedure (i/o-error-position (condition i/o-invalid-position-error?) ) ⟹ *

    This condition type could be defined by

    (define-condition-type &i/o-invalid-position &i/o

    make-i/o-invalid-position-error

    i/o-invalid-position-error?

    (position i/o-error-position))

    This condition type describes attempts to set the file position to an invalid position. Position should be the file position that the program intended to set. This condition describes a range error, but not an assertion violation.

    &i/o-filenamerecord-type-descriptor?

    (rnrs io ports (6)) procedure (make-i/o-filename-error filename ) ⟹ i/o-filename-error?

    (rnrs io ports (6)) procedure (i/o-filename-error? obj ) ⟹ boolean?

    (rnrs io ports (6)) procedure (i/o-error-filename (condition i/o-filename-error?) ) ⟹ *

    This condition type could be defined by

    (define-condition-type &i/o-filename &i/o

    make-i/o-filename-error i/o-filename-error?

    (filename i/o-error-filename))

    This condition type describes an I/O error that occurred during an operation on a named file. Filename should be the name of the file.

    &i/o-file-protectionrecord-type-descriptor?

    (rnrs io ports (6)) procedure (make-i/o-file-protection-error file ) ⟹ i/o-file-protection-error?

    (rnrs io ports (6)) procedure (i/o-file-protection-error? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &i/o-file-protection

    &i/o-filename

    make-i/o-file-protection-error

    i/o-file-protection-error?)

    A condition of this type specifies that an operation tried to operate on a named file with insufficient access rights.

    &i/o-file-is-read-onlyrecord-type-descriptor?

    (rnrs io ports (6)) procedure (make-i/o-file-is-read-only-error file ) ⟹ i/o-file-is-read-only-error?

    (rnrs io ports (6)) procedure (i/o-file-is-read-only-error? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &i/o-file-is-read-only

    &i/o-file-protection

    make-i/o-file-is-read-only-error

    i/o-file-is-read-only-error?)

    A condition of this type specifies that an operation tried to operate on a named read-only file under the assumption that it is writeable.

    &i/o-file-already-existsrecord-type-descriptor?

    (rnrs io ports (6)) procedure (make-i/o-file-already-exists-error file ) ⟹ i/o-file-already-exists-error?

    (rnrs io ports (6)) procedure (i/o-file-already-exists-error? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &i/o-file-already-exists

    &i/o-filename

    make-i/o-file-already-exists-error

    i/o-file-already-exists-error?)

    A condition of this type specifies that an operation tried to operate on an existing named file under the assumption that it did not exist.

    &i/o-file-does-not-existrecord-type-descriptor?

    (rnrs io ports (6)) procedure (make-i/o-file-does-not-exist-error file ) ⟹ i/o-file-does-not-exist-error?

    (rnrs io ports (6)) procedure (i/o-file-does-not-exist-error? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &i/o-file-does-not-exist

    &i/o-filename

    make-i/o-file-does-not-exist-error

    i/o-file-does-not-exist-error?)

    A condition of this type specifies that an operation tried to operate on an non-existent named file under the assumption that it existed.

    &i/o-portrecord-type-descriptor?

    (rnrs io ports (6)) procedure (make-i/o-port-error (port port?) ) ⟹ i/o-port-error?

    (rnrs io ports (6)) procedure (i/o-port-error? obj ) ⟹ boolean?

    (rnrs io ports (6)) procedure (i/o-error-port (condition i/o-port-error?) ) ⟹ port?

    This condition type could be defined by

    (define-condition-type &i/o-port &i/o

    make-i/o-port-error i/o-port-error?

    (port i/o-error-port))

    This condition type specifies the port with which an I/O error is associated. Port should be the port. Conditions raised by procedures accepting a port as an argument should include an &i/o-port-error condition.

    library (rnrs io simple (6))

    (rnrs io simple (6)) procedure (eof-object ) ⟹ eof-object?

    Returns the end-of-file object.

    (rnrs io simple (6)) procedure (eof-object? obj ) ⟹ boolean?

    Returns #t if obj is the end-of-file object, #f otherwise.

    (rnrs io simple (6)) procedure (call-with-input-file (string string?) (proc procedure?) ) ⟹ *

    (proc (port input-port?) ) ⟹ *

    (rnrs io simple (6)) procedure (call-with-output-file (string string?) (proc procedure?) ) ⟹ *

    (proc (port output-port?) ) ⟹ *

    Proc should accept one argument. These procedures open the file named by filename for input or for output, with no specified file options, and call proc with the obtained port as an argument. If proc returns, the port is closed automatically and the values returned by proc are returned. If proc does not return, the port is not closed automatically, unless it is possible to prove that the port will never again be used for an I/O operation.

    (rnrs io simple (6)) procedure (input-port? obj ) ⟹ boolean?

    Returns #t if the argument is an input port (or a combined input and output port), and returns #f otherwise.

    (rnrs io simple (6)) procedure (output-port? obj ) ⟹ boolean?

    Returns #t if the argument is an output port (or a combined input and output port), #f otherwise.

    (rnrs io simple (6)) procedure (current-error-port ) ⟹ output-port?

    This returns a default textual port for input. Normally, this default port is associated with standard input, but can be dynamically re-assigned using the with-input-from-file procedure from the (rnrs io simple (6)) library (see section 8.3). The port may or may not have an associated transcoder; if it does, the transcoder is implementation-dependent.

    (rnrs io simple (6)) procedure (current-input-port ) ⟹ input-port?

    (rnrs io simple (6)) procedure (current-output-port ) ⟹ output-port?

    These return default textual ports for regular output and error output. Normally, these default ports are associated with standard output, and standard error, respectively. The return value of current-output-port can be dynamically re-assigned using the with-output-to-file procedure. A port returned by one of these procedures may or may not have an associated transcoder; if it does, the transcoder is implementation-dependent.

    (rnrs io simple (6)) procedure (with-input-from-file (string string?) (thunk procedure?) ) ⟹ *

    (thunk ) ⟹ *

    (rnrs io simple (6)) procedure (with-output-to-file (string string?) (thunk procedure?) ) ⟹ *

    (thunk ) ⟹ *

    Thunk must be a procedure and must accept zero arguments. The file is opened for input or output using empty file options, and thunk is called with no arguments. During the dynamic extent of the call to thunk, the obtained port is made the value returned by current-input-port or current-output-port procedures; the previous default values are reinstated when the dynamic extent is exited. When thunk returns, the port is closed automatically. The values returned by thunk are returned. If an escape procedure is used to escape back into the call to thunk after thunk is returned, the behavior is unspecified.

    (rnrs io simple (6)) procedure (open-input-file (string string?) ) ⟹ input-port?

    Opens filename for input, with empty file options, and returns the obtained port.

    (rnrs io simple (6)) procedure (open-output-file (string string?) ) ⟹ output-port?

    Opens filename for output, with empty file options, and returns the obtained port.

    (rnrs io simple (6)) procedure (close-input-port (input-port input-port?) ) ⟹ undefined

    (rnrs io simple (6)) procedure (close-output-port (output-port output-port?) ) ⟹ undefined

    Closes input-port or output-port, respectively.

    (rnrs io simple (6)) procedure (read-char ) ⟹ eof-object? / char? /

    (rnrs io simple (6)) procedure (read-char (port input-port?) ) ⟹ eof-object? / char? /

    Reads from textual-input-port, blocking as necessary until a character is available from textual-input-port, or the data that are available cannot be the prefix of any valid encoding, or an end of file is reached.

    If a complete character is available before the next end of file, read-char returns that character, and updates the input port to point past that character. If an end of file is reached before any data are read, read-char returns the end-of-file object.

    If textual-input-port is omitted, it defaults to the value returned by current-input-port.

    (rnrs io simple (6)) procedure (peek-char ) ⟹ eof-object? / char? /

    (rnrs io simple (6)) procedure (peek-char (port input-port?) ) ⟹ eof-object? / char? /

    This is the same as read-char, but does not consume any data from the port.

    (rnrs io simple (6)) procedure (read ) ⟹ *

    (rnrs io simple (6)) procedure (read (port input-port?) ) ⟹ *

    Reads an external representation from textual-input-port and returns the datum it represents. The read procedure operates in the same way as get-datum, see section 8.2.9.

    If textual-input-port is omitted, it defaults to the value returned by current-input-port.

    (rnrs io simple (6)) procedure (write-char (char char?) ) ⟹ undefined

    (rnrs io simple (6)) procedure (write-char (char char?) (port output-port?) ) ⟹ undefined

    Writes an encoding of the character char to the textual-output-port, and returns unspecified values.

    If textual-output-port is omitted, it defaults to the value returned by current-output-port.

    (rnrs io simple (6)) procedure (newline ) ⟹ undefined

    (rnrs io simple (6)) procedure (newline (port output-port?) ) ⟹ undefined

    This is equivalent to using write-char to write #\linefeed to textual-output-port.

    If textual-output-port is omitted, it defaults to the value returned by current-output-port.

    (rnrs io simple (6)) procedure (display obj ) ⟹ undefined

    (rnrs io simple (6)) procedure (display obj (port output-port?) ) ⟹ undefined

    Writes a representation of obj to the given textual-output-port. Strings that appear in the written representation are not enclosed in doublequotes, and no characters are escaped within those strings. Character objects appear in the representation as if written by write-char instead of by write. The display procedure returns unspecified values. The textual-output-port argument may be omitted, in which case it defaults to the value returned by current-output-port.

    (rnrs io simple (6)) procedure (write obj ) ⟹ undefined

    (rnrs io simple (6)) procedure (write obj (port output-port?) ) ⟹ undefined

    Writes the external representation of obj to textual-output-port. The write procedure operates in the same way as put-datum; see section 8.2.12.

    If textual-output-port is omitted, it defaults to the value returned by current-output-port.

    library (rnrs io simple (6))

    &i/orecord-type-descriptor?

    (rnrs io simple (6)) procedure (make-i/o-error ) ⟹ i/o-error?

    (rnrs io simple (6)) procedure (i/o-error? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &i/o &error

    make-i/o-error i/o-error?)

    This is a supertype for a set of more specific I/O errors.

    &i/o-readrecord-type-descriptor?

    (rnrs io simple (6)) procedure (make-i/o-read-error ) ⟹ i/o-read-error?

    (rnrs io simple (6)) procedure (i/o-read-error? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &i/o-read &i/o

    make-i/o-read-error i/o-read-error?)

    This condition type describes read errors that occurred during an I/O operation.

    &i/o-writerecord-type-descriptor?

    (rnrs io simple (6)) procedure (make-i/o-write-error ) ⟹ i/o-write-error?

    (rnrs io simple (6)) procedure (i/o-write-error? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &i/o-write &i/o

    make-i/o-write-error i/o-write-error?)

    This condition type describes write errors that occurred during an I/O operation.

    &i/o-invalid-positionrecord-type-descriptor?

    (rnrs io simple (6)) procedure (make-i/o-invalid-position-error position ) ⟹ i/o-invalid-position-error?

    (rnrs io simple (6)) procedure (i/o-invalid-position-error? obj ) ⟹ boolean?

    (rnrs io simple (6)) procedure (i/o-error-position (condition i/o-invalid-position-error?) ) ⟹ *

    This condition type could be defined by

    (define-condition-type &i/o-invalid-position &i/o

    make-i/o-invalid-position-error

    i/o-invalid-position-error?

    (position i/o-error-position))

    This condition type describes attempts to set the file position to an invalid position. Position should be the file position that the program intended to set. This condition describes a range error, but not an assertion violation.

    &i/o-filenamerecord-type-descriptor?

    (rnrs io simple (6)) procedure (make-i/o-filename-error filename ) ⟹ i/o-filename-error?

    (rnrs io simple (6)) procedure (i/o-filename-error? obj ) ⟹ boolean?

    (rnrs io simple (6)) procedure (i/o-error-filename (condition i/o-filename-error?) ) ⟹ *

    This condition type could be defined by

    (define-condition-type &i/o-filename &i/o

    make-i/o-filename-error i/o-filename-error?

    (filename i/o-error-filename))

    This condition type describes an I/O error that occurred during an operation on a named file. Filename should be the name of the file.

    &i/o-file-protectionrecord-type-descriptor?

    (rnrs io simple (6)) procedure (make-i/o-file-protection-error file ) ⟹ i/o-file-protection-error?

    (rnrs io simple (6)) procedure (i/o-file-protection-error? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &i/o-file-protection

    &i/o-filename

    make-i/o-file-protection-error

    i/o-file-protection-error?)

    A condition of this type specifies that an operation tried to operate on a named file with insufficient access rights.

    &i/o-file-is-read-onlyrecord-type-descriptor?

    (rnrs io simple (6)) procedure (make-i/o-file-is-read-only-error file ) ⟹ i/o-file-is-read-only-error?

    (rnrs io simple (6)) procedure (i/o-file-is-read-only-error? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &i/o-file-is-read-only

    &i/o-file-protection

    make-i/o-file-is-read-only-error

    i/o-file-is-read-only-error?)

    A condition of this type specifies that an operation tried to operate on a named read-only file under the assumption that it is writeable.

    &i/o-file-already-existsrecord-type-descriptor?

    (rnrs io simple (6)) procedure (make-i/o-file-already-exists-error file ) ⟹ i/o-file-already-exists-error?

    (rnrs io simple (6)) procedure (i/o-file-already-exists-error? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &i/o-file-already-exists

    &i/o-filename

    make-i/o-file-already-exists-error

    i/o-file-already-exists-error?)

    A condition of this type specifies that an operation tried to operate on an existing named file under the assumption that it did not exist.

    &i/o-file-does-not-existrecord-type-descriptor?

    (rnrs io simple (6)) procedure (make-i/o-file-does-not-exist-error file ) ⟹ i/o-file-does-not-exist-error?

    (rnrs io simple (6)) procedure (i/o-file-does-not-exist-error? obj ) ⟹ boolean?

    This condition type could be defined by

    (define-condition-type &i/o-file-does-not-exist

    &i/o-filename

    make-i/o-file-does-not-exist-error

    i/o-file-does-not-exist-error?)

    A condition of this type specifies that an operation tried to operate on an non-existent named file under the assumption that it existed.

    &i/o-portrecord-type-descriptor?

    (rnrs io simple (6)) procedure (make-i/o-port-error (port port?) ) ⟹ i/o-port-error?

    (rnrs io simple (6)) procedure (i/o-port-error? obj ) ⟹ boolean?

    (rnrs io simple (6)) procedure (i/o-error-port (condition i/o-port-error?) ) ⟹ port?

    This condition type could be defined by

    (define-condition-type &i/o-port &i/o

    make-i/o-port-error i/o-port-error?

    (port i/o-error-port))

    This condition type specifies the port with which an I/O error is associated. Port should be the port. Conditions raised by procedures accepting a port as an argument should include an &i/o-port-error condition.

    library (rnrs lists (6))

    (rnrs lists (6)) procedure (find (pred procedure?) (list list?) ) ⟹ *

    (pred obj ) ⟹ *

    Proc should accept one argument and return a single value. Proc should not mutate list. The find procedure applies proc to the elements of list in order. If proc returns a true value for an element, find immediately returns that element. If proc returns #f for all elements of the list, find returns #f. Proc is always called in the same dynamic environment as find itself.

    (rnrs lists (6)) procedure (for-all (pred procedure?) (list1 list?) (list2 list?) ... ) ⟹ *

    (pred obj1 obj2 ... ) ⟹ *

    The lists should all have the same length, and proc should accept n arguments and return a single value. Proc should not mutate the list arguments. For natural numbers i = 0, 1, ..., the for-all procedure successively applies proc to arguments xi1 ... xin, where xij is the ith element of listj, until #f is returned. If proc returns true values for all but the last element of list1, for-all performs a tail call of proc on the kth elements, where k is the length of list1. If proc returns #f on any set of elements, for-all returns #f after the first such application of proc. If the lists are all empty, for-all returns #t.

    (rnrs lists (6)) procedure (exists (pred procedure?) (list1 list?) (list2 list?) ... ) ⟹ *

    (pred obj1 obj2 ... ) ⟹ *

    The lists should all have the same length, and proc should accept n arguments and return a single value. Proc should not mutate the list arguments. For natural numbers i = 0, 1, ..., the exists procedure applies proc successively to arguments xi1 ... xin, where xij is the ith element of listj, until a true value is returned. If proc returns #f for all but the last elements of the lists, exists performs a tail call of proc on the kth elements, where k is the length of list1. If proc returns a true value on any set of elements, exists returns that value after the first such application of proc. If the lists are all empty, exists returns #f.

    (rnrs lists (6)) procedure (filter (pred procedure?) (list list?) ) ⟹ list?

    (pred obj ) ⟹ *

    Proc should accept one argument and return a single value. Proc should not mutate list. The filter procedure applies proc to each element of list and returns a list of the elements of list for which proc returned a true value. The elements of the result list are in the same order as they appear in the input list. Proc is always called in the same dynamic environment as filter. If multiple returns occur from filter, the return values returned by earlier returns are not mutated.

    (rnrs lists (6)) procedure (partition (pred procedure?) (list list?) ) ⟹ (values list?list?)

    (pred obj ) ⟹ *

    Proc should accept one argument and return a single value. Proc should not mutate list. The partition procedure also applies proc to each element of list, but returns two values, the first one a list of the elements of list for which proc returned a true value, and the second a list of the elements of list for which proc returned #f. The elements of the result lists are in the same order as they appear in the input list. Proc is always called in the same dynamic environment as partition itself. If multiple returns occur from partitions, the return values returned by earlier returns are not mutated.

    (rnrs lists (6)) procedure (fold-left (kons procedure?) knil (list1 list?) (list2 list?) ... ) ⟹ *

    (kons obj1 obj2 ... fold-state ) ⟹ *

    The lists should all have the same length. Combine must be a procedure. It should accept one more argument than there are lists and return a single value. It should not mutate the list arguments. The fold-left procedure iterates the combine procedure over an accumulator value and the elements of the lists from left to right, starting with an accumulator value of nil. More specifically, fold-left returns nil if the lists are empty. If they are not empty, combine is first applied to nil and the respective first elements of the lists in order. The result becomes the new accumulator value, and combine is applied to the new accumulator value and the respective next elements of the list. This step is repeated until the end of the list is reached; then the accumulator value is returned. Combine is always called in the same dynamic environment as fold-left itself.

    (rnrs lists (6)) procedure (fold-right (kons procedure?) knil (list1 list?) (list2 list?) ... ) ⟹ *

    (kons obj1 obj2 ... fold-state ) ⟹ *

    The lists should all have the same length. Combine must be a procedure. It should accept one more argument than there are lists and return a single value. Combine should not mutate the list arguments. The fold-right procedure iterates the combine procedure over the elements of the lists from right to left and an accumulator value, starting with an accumulator value of nil. More specifically, fold-right returns nil if the lists are empty. If they are not empty, combine is first applied to the respective last elements of the lists in order and nil. The result becomes the new accumulator value, and combine is applied to the respective previous elements of the lists and the new accumulator value. This step is repeated until the beginning of the list is reached; then the accumulator value is returned. Proc is always called in the same dynamic environment as fold-right itself.

    (rnrs lists (6)) procedure (remp (pred procedure?) (list list?) ) ⟹ list?

    (pred obj ) ⟹ *

    The remp procedure applies proc to each element of list and returns a list of the elements of list for which proc returned #f.

    (rnrs lists (6)) procedure (remove obj (list list?) ) ⟹ list?

    The remove procedure return a list of the elements that are not obj as according to equal?.

    (rnrs lists (6)) procedure (remv obj (list list?) ) ⟹ list?

    The remv procedure return a list of the elements that are not obj as according to eqv?.

    (rnrs lists (6)) procedure (remq obj (list list?) ) ⟹ list?

    The remq procedure return a list of the elements that are not obj as according to eq?.

    (rnrs lists (6)) procedure (memp (pred procedure?) (list list?) ) ⟹ #f / list? /

    (pred obj ) ⟹ *

    Proc should accept one argument and return a single value. Proc should not mutate list. Returns the first sublist of list whose car satisfies a given condition, where the sublists of lists are the lists returned by (list-tail list k) for k less than the length of list. The memp procedure applies proc to the cars of the sublists of list until it finds one for which proc returns a true value. Proc is always called in the same dynamic environment as memp itself. If list does not contain an element satisfying the condition, then #f (not the empty list) is returned.

    (rnrs lists (6)) procedure (member obj (list list?) ) ⟹ #f / list? /

    Returns the first sublist of list whose car satisfies a given condition, where the sublists of lists are the lists returned by (list-tail list k) for k less than the length of list. The member procedure looks for the first occurrence of obj. If list does not contain an element satisfying the condition, then #f (not the empty list) is returned. The member procedure uses equal? to compare obj with the elements of list.

    (rnrs lists (6)) procedure (memq obj (list list?) ) ⟹ #f / list? /

    Returns the first sublist of list whose car satisfies a given condition, where the sublists of lists are the lists returned by (list-tail list k) for k less than the length of list. The memq procedure looks for the first occurrence of obj. If list does not contain an element satisfying the condition, then #f (not the empty list) is returned. The memq procedure uses eq? to compare obj with the elements of list.

    (rnrs lists (6)) procedure (memv obj (list list?) ) ⟹ #f / list? /

    Returns the first sublist of list whose car satisfies a given condition, where the sublists of lists are the lists returned by (list-tail list k) for k less than the length of list. The memv procedure looks for the first occurrence of obj. If list does not contain an element satisfying the condition, then #f (not the empty list) is returned. The memv procedure uses eqv? to compare obj with the elements of list.

    (rnrs lists (6)) procedure (assp (pred procedure?) (alist list?) ) ⟹ pair? / #f /

    (pred obj ) ⟹ *

    alist ⟹ (alist key : value)

    Alist (for "association list") should be a list of pairs. Proc should accept one argument and return a single value. Proc should not mutate alist. The procedure finds the first pair in alist whose car field satisfies a given condition, and returns that pair without traversing alist further. If no pair in alist satisfies the condition, then #f is returned. The assp procedure successively applies proc to the car fields of alist and looks for a pair for which it returns a true value. Proc is always called in the same dynamic environment as assp itself.

    (rnrs lists (6)) procedure (assoc obj (alist list?) ) ⟹ pair? / #f /

    alist ⟹ (alist key : value)

    Alist (for "association list") should be a list of pairs. The procedure finds the first pair in alist whose car field satisfies a given condition, and returns that pair without traversing alist further. If no pair in alist satisfies the condition, then #f is returned. The assoc procedure looks for a pair that has obj as its car. The assoc procedure uses equal? to compare obj with the car fields of the pairs in alist.

    (rnrs lists (6)) procedure (assq obj (alist list?) ) ⟹ pair? / #f /

    alist ⟹ (alist key : value)

    Alist (for "association list") should be a list of pairs. The procedure finds the first pair in alist whose car field satisfies a given condition, and returns that pair without traversing alist further. If no pair in alist satisfies the condition, then #f is returned. The assoc procedure looks for a pair that has obj as its car. The assq procedure uses eq? to compare obj with the car fields of the pairs in alist.

    (rnrs lists (6)) procedure (assv obj (alist list?) ) ⟹ pair? / #f /

    alist ⟹ (alist key : value)

    Alist (for "association list") should be a list of pairs. The procedure finds the first pair in alist whose car field satisfies a given condition, and returns that pair without traversing alist further. If no pair in alist satisfies the condition, then #f is returned. The assoc procedure looks for a pair that has obj as its car. The assv procedure uses eqv? to compare obj with the car fields of the pairs in alist.

    (rnrs lists (6)) procedure (cons* elt1 elt2 ... ) ⟹ *

    If called with at least two arguments, cons* returns a freshly allocated chain of pairs whose cars are obj1, ..., objn, and whose last cdr is obj. If called with only one argument, cons* returns that argument.

    library (rnrs mutable-pairs (6))

    (rnrs mutable-pairs (6)) procedure (set-car! (pair pair?) obj ) ⟹ undefined

    Stores obj in the car field of pair. The set-car! procedure returns unspecified values. If an immutable pair is passed to set-car!, an exception with condition type &assertion should be raised.

    (rnrs mutable-pairs (6)) procedure (set-cdr! (pair pair?) obj ) ⟹ undefined

    Stores obj in the cdr field of pair. The set-cdr! procedure returns unspecified values. If an immutable pair is passed to set-car!, an exception with condition type &assertion should be raised.

    library (rnrs mutable-strings (6))

    (rnrs mutable-strings (6)) procedure (string-set! (string string?) (k integer?) (char char?) ) ⟹ undefined

    K must be a valid index of string. The string-set! procedure stores char in element k of string and returns unspecified values. Passing an immutable string to string-set! should cause an exception with condition type &assertion to be raised.

    (rnrs mutable-strings (6)) procedure (string-fill! (string string?) (fill char?) ) ⟹ undefined

    Stores char in every element of the given string and returns unspecified values.

    library (rnrs programs (6))

    (rnrs programs (6)) procedure (command-line ) ⟹ list?

    Returns a nonempty list of strings. The first element is an implementation-specific name for the running top-level program. The remaining elements are command-line arguments according to the operating system's conventions.

    (rnrs programs (6)) procedure (exit ) ⟹ undefined

    (rnrs programs (6)) procedure (exit obj ) ⟹ undefined

    Exits the running program and communicates an exit value to the operating system. If no argument is supplied, the exit procedure should communicate to the operating system that the program exited normally. If an argument is supplied, the exit procedure should translate the argument into an appropriate exit value for the operating system. If obj is #f, the exit is assumed to be abnormal.

    library (rnrs r5rs (6))

    (rnrs r5rs (6)) procedure (exact->inexact (z number?) ) ⟹ inexact?

    (rnrs r5rs (6)) procedure (inexact->exact (z number?) ) ⟹ exact?

    These are the same as the inexact and exact procedures

    (rnrs r5rs (6)) procedure (quotient (n1 integer?) (n2 integer?) ) ⟹ integer?

    (rnrs r5rs (6)) procedure (remainder (n1 integer?) (n2 integer?) ) ⟹ integer?

    (rnrs r5rs (6)) procedure (modulo (n1 integer?) (n2 integer?) ) ⟹ integer?

    These procedures implement number-theoretic (integer) division. N2 must be non-zero.

    (rnrs r5rs (6)) syntax (delay () ((_ expression) promise?) )

    The delay construct is used together with the procedure force to implement lazy evaluation or call by need. (delay <expression>) returns an object called a promise which at some point in the future may be asked (by the force procedure) to evaluate <expression>, and deliver the resulting value. The effect of <expression> returning multiple values is unspecified.

    (rnrs r5rs (6)) procedure (force (promise promise?) ) ⟹ *

    Promise must be a promise. The force procedure forces the value of promise. If no value has been computed for the promise, then a value is computed and returned. The value of the promise is cached (or “memoized”) so that if it is forced a second time, the previously computed value is returned.

    (rnrs r5rs (6)) procedure (null-environment (n integer?) ) ⟹ environment

    (rnrs r5rs (6)) procedure (null-environment (n integer?) ) ⟹ environment

    N must be the exact integer object 5. The null-environment procedure returns an environment specifier suitable for use with eval (see chapter 16) representing an environment that is empty except for the (syntactic) bindings for all keywords described in the previous revision of this report, including bindings for =>, ..., else, and _ that are the same as those in the (rnrs base (6)) library.

    (rnrs r5rs (6)) procedure (scheme-report-environment (n integer?) ) ⟹ environment

    N must be the exact integer object 5. The scheme-report-environment procedure returns an environment specifier for an environment that is empty except for the bindings for the identifiers described in the previous revision of this report, omitting load, interaction-environment, transcript-on, transcript-off, and char-ready?. The variable bindings have as values the procedures of the same names described in this report, and the keyword bindings, including =>, ..., else, and _ are the same as those described in this report.

    library (rnrs records inspection (6))

    (rnrs records inspection (6)) procedure (record? obj ) ⟹ boolean?

    Returns #t if obj is a record, and its record type is not opaque, and returns #f otherwise.

    (rnrs records inspection (6)) procedure (record-rtd (record record?) ) ⟹ record-type-descriptor?

    Returns the rtd representing the type of record if the type is not opaque. The rtd of the most precise type is returned; that is, the type t such that record is of type t but not of any type that extends t. If the type is opaque, an exception is raised with condition type &assertion.

    (rnrs records inspection (6)) procedure (record-type-name (rtd record-type-descriptor?) ) ⟹ symbol?

    Returns the name of the record-type descriptor rtd.

    (rnrs records inspection (6)) procedure (record-type-parent (rtd record-type-descriptor?) ) ⟹ #f / record-type-descriptor? /

    Returns the parent of the record-type descriptor rtd, or #f if it has none.

    (rnrs records inspection (6)) procedure (record-type-uid (rtd record-type-descriptor?) ) ⟹ symbol? / #f /

    Returns the uid of the record-type descriptor rtd, or #f if it has none. (An implementation may assign a generated uid to a record type even if the type is generative, so the return of a uid does not necessarily imply that the type is nongenerative.)

    (rnrs records inspection (6)) procedure (record-type-generative? (rtd record-type-descriptor?) ) ⟹ boolean?

    Returns #t if rtd is generative, and #f if not.

    (rnrs records inspection (6)) procedure (record-type-sealed? (rtd record-type-descriptor?) ) ⟹ boolean?

    Returns #t if the record-type descriptor is sealed, and #f if not.

    (rnrs records inspection (6)) procedure (record-type-opaque? (rtd record-type-descriptor?) ) ⟹ boolean?

    Returns #t if the the record-type descriptor is opaque, and #f if not.

    (rnrs records inspection (6)) procedure (record-type-field-names (rtd record-type-descriptor?) ) ⟹ vector?

    Returns a vector of symbols naming the fields of the type represented by rtd (not including the fields of parent types) where the fields are ordered as described under make-record-type-descriptor. The returned vector may be immutable. If the returned vector is modified, the effect on rtd is unspecified.

    (rnrs records inspection (6)) procedure (record-field-mutable? (rtd record-type-descriptor?) (k integer?) ) ⟹ boolean?

    Returns #t if the field specified by k of the type represented by rtd is mutable, and #f if not. K is as in record-accessor.

    library (rnrs records procedural (6))

    (rnrs records procedural (6)) procedure (make-record-type-descriptor (name symbol?) (parent (or #frecord-type-descriptor?)) (uid (or #fsymbol?)) (sealed? boolean?) (opaque? boolean?) (fields vector?) ) ⟹ record-type-descriptor?

    Returns a record-type descriptor, or rtd, representing a record type distinct from all built-in types and other record types.

    The name argument must be a symbol. It names the record type, and is intended purely for informational purposes and may be used for printing by the underlying Scheme system.

    The parent argument must be either #f or an rtd. If it is an rtd, the returned record type, t, extends the record type p represented by parent. An exception with condition type &assertion is raised if parent is sealed (see below).

    The uid argument must be either #f or a symbol. If uid is a symbol, the record-creation operation is nongenerative i.e., a new record type is created only if no previous call to make-record-type-descriptor was made with the uid. If uid is #f, the record-creation operation is generative, i.e., a new record type is created even if a previous call to make-record-type-descriptor was made with the same arguments.

    If make-record-type-descriptor is called twice with the same uid symbol, the parent arguments in the two calls must be eqv?, the fields arguments equal?, the sealed? arguments boolean-equivalent (both #f or both true), and the opaque? arguments boolean-equivalent. If these conditions are not met, an exception with condition type &assertion is raised when the second call occurs. If they are met, the second call returns, without creating a new record type, the same record-type descriptor (in the sense of eqv?) as the first call.

    Note: Users are encouraged to use symbol names constructed using the UUID namespace [10] (for example, using the record-type name as a prefix) for the uid argument.

    The sealed? flag must be a boolean. If true, the returned record type is sealed, i.e., it cannot be extended.

    The opaque? flag must be a boolean. If true, the record type is opaque. If passed an instance of the record type, record? returns #f. Moreover, if record-rtd (see “Inspection” below) is called with an instance of the record type, an exception with condition type &assertion is raised. The record type is also opaque if an opaque parent is supplied. If opaque? is #f and an opaque parent is not supplied, the record is not opaque.

    The fields argument must be a vector of field specifiers. Each field specifier must be a list of the form (mutable name) or a list of the form (immutable name). Each name must be a symbol and names the corresponding field of the record type; the names need not be distinct. A field identified as mutable may be modified, whereas, when a program attempts to obtain a mutator for a field identified as immutable, an exception with condition type &assertion is raised. Where field order is relevant, e.g., for record construction and field access, the fields are considered to be ordered as specified, although no particular order is required for the actual representation of a record instance.

    The specified fields are added to the parent fields, if any, to determine the complete set of fields of the returned record type. If fields is modified after make-record-type-descriptor has been called, the effect on the returned rtd is unspecified.

    A generative record-type descriptor created by a call to make-record-type-descriptor is not eqv? to any record-type descriptor (generative or nongenerative) created by another call to make-record-type-descriptor. A generative record-type descriptor is eqv? only to itself, i.e., (eqv? rtd1 rtd2) iff (eq? rtd1 rtd2). Also, two nongenerative record-type descriptors are eqv? iff they were created by calls to make-record-type-descriptor with the same uid arguments.

    (rnrs records procedural (6)) procedure (record-type-descriptor? obj ) ⟹ boolean?

    Returns #t if the argument is a record-type descriptor, #f otherwise.

    (rnrs records procedural (6)) procedure (make-record-constructor-descriptor (rtd record-type-descriptor?) (parent-constructor-descriptor (or constructor-descriptor#f)) (protocol (or #fprocedure?)) ) ⟹ constructor-descriptor

    (protocol (p procedure?) ) ⟹ procedure?

    Returns a record-constructor descriptor (or constructor descriptor for short) that specifies a record constructor (or constructor for short), that can be used to construct record values of the type specified by rtd, and which can be obtained via record-constructor. A constructor descriptor can also be used to create other constructor descriptors for subtypes of its own record type. Rtd must be a record-type descriptor. Protocolmust be a procedure or #f. If it is #f, a default protocol procedure is supplied.

    If protocol is a procedure, it is handled analogously to the protocol expression in a define-record-type form.

    If rtd is a base record type and protocol is a procedure, parent-constructor-descriptor must be #f. In this case, protocol is called by record-constructor with a single argument p. P is a procedure that expects one argument for every field of rtd and returns a record with the fields of rtd initialized to these arguments. The procedure returned by protocol should call p once with the number of arguments p expects and return the resulting record as shown in the simple example below:

    (lambda (p)

    (lambda (v1 v2 v3)

    (p v1 v2 v3)))

    Here, the call to p returns a record whose fields are initialized with the values of v1, v2, and v3. The expression above is equivalent to (lambda (p) p). Note that the procedure returned by protocol is otherwise unconstrained; specifically, it can take any number of arguments.

    If rtd is an extension of another record type parent-rtd and protocol is a procedure, parent-constructor-descriptor must be a constructor descriptor of parent-rtd or #f. If parent-constructor-descriptor is a constructor descriptor, protocol it is called by record-constructor with a single argument n, which is a procedure that accepts the same number of arguments as the constructor of parent-constructor-descriptor and returns a procedure p that, when called, constructs the record itself. The p procedure expects one argument for every field of rtd (not including parent fields) and returns a record with the fields of rtd initialized to these arguments, and the fields of parent-rtd and its parents initialized as specified by parent-constructor-descriptor.

    The procedure returned by protocol should call n once with the number of arguments n expects, call the procedure p it returns once with the number of arguments p expects and return the resulting record. A simple protocol in this case might be written as follows:

    (lambda (n)

    (lambda (v1 v2 v3 x1 x2 x3 x4)

    (let ((p (n v1 v2 v3)))

    (p x1 x2 x3 x4))))

    This passes arguments v1, v2, v3 to n for parent-constructor-descriptor and calls p with x1, ..., x4 to initialize the fields of rtd itself.

    Thus, the constructor descriptors for a record type form a sequence of protocols parallel to the sequence of record-type parents. Each constructor descriptor in the chain determines the field values for the associated record type. Child record constructors need not know the number or contents of parent fields, only the number of arguments accepted by the parent constructor.

    Protocol may be #f, specifying a default constructor that accepts one argument for each field of rtd (including the fields of its parent type, if any). Specifically, if rtd is a base type, the default protocol procedure behaves as if it were (lambda (p) p). If rtd is an extension of another type, then parent-constructor-descriptor must be either #f or itself specify a default constructor, and the default protocol procedure behaves as if it were:

    (lambda (n)

    (lambda (v1 ... vj x1 ... xk)

    (let ((p (n v1 ... vj)))

    (p x1 ... xk))))

    The resulting constructor accepts one argument for each of the record type's complete set of fields (including those of the parent record type, the parent's parent record type, etc.) and returns a record with the fields initialized to those arguments, with the field values for the parent coming before those of the extension in the argument list. (In the example, j is the complete number of fields of the parent type, and k is the number of fields of rtd itself.)

    If rtd is an extension of another record type, and parent-constructor-descriptor or the protocol of parent-constructor-descriptor is #f, protocol must also be #f, and a default constructor descriptor as described above is also assumed.

    (rnrs records procedural (6)) procedure (record-constructor (constructor-descriptor constructor-descriptor) ) ⟹ procedure?

    Calls the protocol of constructor-descriptor (as described for make-record-constructor-descriptor) and returns the resulting constructor constructor for records of the record type associated with constructor-descriptor.

    (rnrs records procedural (6)) procedure (record-predicate (rtd record-type-descriptor?) ) ⟹ procedure?

    (return obj ) ⟹ boolean?

    Returns a procedure that, given an object obj, returns #t if obj is a record of the type represented by rtd, and #f otherwise.

    (rnrs records procedural (6)) procedure (record-accessor (rtd record-type-descriptor?) (k integer?) ) ⟹ procedure?

    (return record ) ⟹ *

    K must be a valid field index of rtd. The record-accessor procedure returns a one-argument procedure whose argument must be a record of the type represented by rtd. This procedure returns the value of the selected field of that record.

    The field selected corresponds to the kth element (0-based) of the fields argument to the invocation of make-record-type-descriptor that created rtd. Note that k cannot be used to specify a field of any type rtd extends.

    (rnrs records procedural (6)) procedure (record-mutator (rtd record-type-descriptor?) (k integer?) ) ⟹ procedure?

    (return record obj ) ⟹ undefined

    K must be a valid field index of rtd. The record-mutator procedure returns a two-argument procedure whose arguments must be a record record r of the type represented by rtd and an object obj. This procedure stores obj within the field of r specified by k. The k argument is as in record-accessor. If k specifies an immutable field, an exception with condition type &assertion is raised. The mutator returns unspecified values.

    library (rnrs records syntactic (6))

    (rnrs records syntactic (6)) syntax (define-record-type (fields immutable mutable parent protocol sealed opaque nongenerative parent-rtd ) ((_ name-spec record-clause ...)) )

    (record-name constructor-name predicate-name) record-name

    (fields field-spec ...) (parent parent-name) (protocol expression) (sealed #t) (sealed #f) (opaque #t) (opaque #f) (nongenerative uid) (nongenerative) (parent-rtd parentrtd parentcd)

    (immutable field-name accessor-name) (mutable field-name accessor-name mutator-name) (immutable field-name) (mutable field-name) field-name

    A define-record-type form defines a record type along with associated constructor descriptor and constructor, predicate, field accessors, and field mutators. The define-record-type form expands into a set of definitions in the environment where define-record-type appears; hence, it is possible to refer to the bindings (except for that of the record type itself) recursively.

    The <name spec> specifies the names of the record type, constructor, and predicate. It must take one of the following forms:

    (<record name> <constructor name> <predicate name>)

    <record name>

    <Record name>, <constructor name>, and <predicate name> must all be identifiers.

    <Record name>, taken as a symbol, becomes the name of the record type. (See the description of make-record-type-descriptor below.) Additionally, it is bound by this definition to an expand-time or run-time representation of the record type and can be used as parent name in syntactic record-type definitions that extend this definition. It can also be used as a handle to gain access to the underlying record-type descriptor and constructor descriptor (see record-type-descriptor and record-constructor-descriptor below).

    <Constructor name> is defined by this definition to be a constructor for the defined record type, with a protocol specified by the protocol clause, or, in its absence, using a default protocol. For details, see the description of the protocol clause below.

    <Predicate name> is defined by this definition to a predicate for the defined record type.

    The second form of <name spec> is an abbreviation for the first form, where the name of the constructor is generated by prefixing the record name with make-, and the predicate name is generated by adding a question mark (?) to the end of the record name. For example, if the record name is frob, the name of the constructor is make-frob, and the predicate name is frob?.

    Each <record clause> must take one of the following forms; it is a syntax violation if multiple <record clause>s of the same kind appear in a define-record-type form.

    (fields <field spec>*)

    Each <field spec> has one of the following forms

    (immutable <field name> <accessor name>)

    (mutable <field name>

    <accessor name> <mutator name>)

    (immutable <field name>)

    (mutable <field name>)

    <field name>

    <Field name>, <accessor name>, and <mutator name> must all be identifiers. The first form declares an immutable field called <field name>, with the corresponding accessor named <accessor name>. The second form declares a mutable field called <field name>, with the corresponding accessor named <accessor name>, and with the corresponding mutator named <mutator name>.

    If <field spec> takes the third or fourth form, the accessor name is generated by appending the record name and field name with a hyphen separator, and the mutator name (for a mutable field) is generated by adding a -set! suffix to the accessor name. For example, if the record name is frob and the field name is widget, the accessor name is frob-widget and the mutator name is frob-widget-set!.

    If <field spec> is just a <field name> form, it is an abbreviation for (immutable <field name>).

    The <field name>s become, as symbols, the names of the fields in the record-type descriptor being created, in the same order.

    The fields clause may be absent; this is equivalent to an empty fields clause.

    (parent <parent name>)

    Specifies that the record type is to have parent type <parent name>, where <parent name> is the <record name> of a record type previously defined using define-record-type. The record-type definition associated with <parent name> must not be sealed. If no parent clause and no parent-rtd (see below) clause is present, the record type is a base type.

    (protocol <expression>)

    <Expression> is evaluated in the same environment as the define-record-type form, and must evaluate to a protocol appropriate for the record type being defined.

    The protocol is used to create a record-constructor descriptor as described below. If no protocol clause is specified, a constructor descriptor is still created using a default protocol. The clause can be absent only if the record type being defined has no parent type, or if the parent definition does not specify a protocol.

    (sealed #t)

    (sealed #f)

    If this option is specified with operand #t, the defined record type is sealed, i.e., no extensions of the record type can be created. If this option is specified with operand #f, or is absent, the defined record type is not sealed.

    (opaque #t)

    (opaque #f)

    If this option is specified with operand #t, or if an opaque parent record type is specified, the defined record type is opaque. Otherwise, the defined record type is not opaque. See the specification of record-rtd below for details.

    (nongenerative <uid>)

    (nongenerative)

    This specifies that the record type is nongenerative with uid <uid>, which must be an <identifier>. If <uid> is absent, a unique uid is generated at macro-expansion time. If two record-type definitions specify the same uid, then the record-type definitions should be equivalent, i.e., the implied arguments to make-record-type-descriptor must be equivalent as described under make-record-type-descriptor. See section 6.3. If this condition is not met, it is either considered a syntax violation or an exception with condition type &assertion is raised. If the condition is met, a single record type is generated for both definitions.

    In the absence of a nongenerative clause, a new record type is generated every time a define-record-type form is evaluated:

    (let ((f (lambda (x)

    (define-record-type r ...)

    (if x r? (make-r ...)))))

    ((f #t) (f #f))) => #f

    (parent-rtd <parent rtd> <parent cd>)

    Specifies that the record type is to have its parent type specified by <parent rtd>, which should be an expression evaluating to a record-type descriptor, and <parent cd>, which should be an expression evaluating to a constructor descriptor (see below). The record-type definition associated with the value of <parent rtd> must not be sealed. Moreover, a record-type definition must not have both a parent and a parent-rtd clause.

    Note: The syntactic layer is designed to allow record-instance sizes and field offsets to be determined at expand time, i.e., by a macro definition of define-record-type, as long as the parent (if any) is known. Implementations that take advantage of this may generate less efficient constructor, accessor, and mutator code when the parent-rtd clause is used, since the type of the parent is generally not known until run time. The parent clause should therefore be used instead when possible.

    All bindings created by define-record-type (for the record type, the constructor, the predicate, the accessors, and the mutators) must have names that are pairwise distinct.

    The constructor created by a define-record-type form is a procedure as follows:

  • If there is no parent clause and no protocol clause, the constructor accepts as many arguments as there are fields, in the same order as they appear in the fields clause, and returns a record object with the fields initialized to the corresponding arguments.
  • If there is no parent or parent-rtd clause and a protocol clause, the protocol expression must evaluate to a procedure that accepts a single argument. The protocol procedure is called once during the evaluation of the define-record-type form with a procedure p as its argument. It should return a procedure, which will become the constructor bound to <constructor name>. The procedure p accepts as many arguments as there are fields, in the same order as they appear in the fields clause, and returns a record object with the fields initialized to the corresponding arguments.
  • The constructor returned by the protocol procedure can accept an arbitrary number of arguments, and should call p once to construct a record object, and return that record object.

    For example, the following protocol expression for a record-type definition with three fields creates a constructor that accepts values for all fields, and initialized them in the reverse order of the arguments:

    (lambda (p)

    (lambda (v1 v2 v3)

    (p v3 v2 v1)))

  • If there is both a parent clause and a protocol clause, then the protocol procedure is called once with a procedure n as its argument. As in the previous case, the protocol procedure should return a procedure, which will become the constructor bound to <constructor name>. However, n is different from p in the previous case: It accepts arguments corresponding to the arguments of the constructor of the parent type. It then returns a procedure p that accepts as many arguments as there are (additional) fields in this type, in the same order as in the fields clause, and returns a record object with the fields of the parent record types initialized according to their constructors and the arguments to n, and the fields of this record type initialized to its arguments of p.
  • The constructor returned by the protocol procedure can accept an arbitrary number of arguments, and should call n once to construct the procedure p, and call p once to create the record object, and finally return that record object.

    For example, the following protocol expression assumes that the constructor of the parent type takes three arguments:

    (lambda (n)

    (lambda (v1 v2 v3 x1 x2 x3 x4)

    (let ((p (n v1 v2 v3)))

    (p x1 x2 x3 x4))))

    The resulting constructor accepts seven arguments, and initializes the fields of the parent types according to the constructor of the parent type, with v1, v2, and v3 as arguments. It also initializes the fields of this record type to the values of x1, ..., x4.

  • If there is a parent clause, but no protocol clause, then the parent type must not have a protocol clause itself. The constructor bound to <constructor name> is a procedure that accepts arguments corresponding to the parent types' constructor first, and then one argument for each field in the same order as in the fields clause. The constructor returns a record object with the fields initialized to the corresponding arguments.
  • If there is a parent-rtd clause, then the constructor is as with a parent clause, except that the constructor of the parent type is determined by the constructor descriptor of the parent-rtd clause.
  • A protocol may perform other actions consistent with the requirements described above, including mutation of the new record or other side effects, before returning the record.

    Any definition that takes advantage of implicit naming for the constructor, predicate, accessor, and mutator names can be rewritten trivially to a definition that specifies all names explicitly. For example, the implicit-naming record definition:

    (define-record-type frob

    (fields (mutable widget))

    (protocol

    (lambda (p)

    (lambda (n) (p (make-widget n))))))

    is equivalent to the following explicit-naming record definition.

    (define-record-type (frob make-frob frob?)

    (fields (mutable widget

    frob-widget

    frob-widget-set!))

    (protocol

    (lambda (p)

    (lambda (n) (p (make-widget n))))))

    Also, the implicit-naming record definition:

    (define-record-type point (fields x y))

    is equivalent to the following explicit-naming record definition:

    (define-record-type (point make-point point?)

    (fields

    (immutable x point-x)

    (immutable y point-y)))

    With implicit naming, it is still possible to specify some of the names explicitly; for example, the following overrides the choice of accessor and mutator names for the widget field.

    (define-record-type frob

    (fields (mutable widget getwid setwid!))

    (protocol

    (lambda (p)

    (lambda (n) (p (make-widget n))))))

    (rnrs records syntactic (6)) syntax (record-type-descriptor () ((_ record-name)) )

    Evaluates to the record-type descriptor associated with the type specified by <record name>.

    (rnrs records syntactic (6)) syntax (record-constructor-descriptor () ((_ record-name)) )

    Evaluates to the record-constructor descriptor associated with <record name>.

    library (rnrs sorting (6))

    (rnrs sorting (6)) procedure (list-sort (< procedure?) (lis list?) ) ⟹ list?

    (< obj1 obj2 ) ⟹ boolean?

    Proc should accept any two elements of list, and should not have any side effects. Proc should return a true value when its first argument is strictly less than its second, and #f otherwise.

    The list-sort procedure performs a stable sort of list in ascending order according to proc, without changing list in any way. The results may be eq? to the argument when the argument is already sorted, and the result of list-sort may share structure with a tail of the original list. The sorting algorithm performs O(n lg n) calls to proc where n is the length of list, and all arguments passed to proc are elements of the list being sorted, but the pairing of arguments and the sequencing of calls to proc are not specified. If multiple returns occur from list-sort, the return values returned by earlier returns are not mutated.

    (rnrs sorting (6)) procedure (vector-sort (< procedure?) (v vector?) ) ⟹ boolean?

    (< obj1 obj2 ) ⟹ boolean?

    Proc should accept any two elements of vector, and should not have any side effects. Proc should return a true value when its first argument is strictly less than its second, and #f otherwise.

    The vector-sort procedure performs a stable sort of vector in ascending order according to proc, without changing vector in any way. The results may be eq? to the argument when the argument is already sorted, and the result of list-sort may share structure with a tail of the original list. The sorting algorithm performs O(n lg n) calls to proc where n is the length of list or vector, and all arguments passed to proc are elements of the list or vector being sorted, but the pairing of arguments and the sequencing of calls to proc are not specified. If multiple returns occur from vector-sort, the return values returned by earlier returns are not mutated.

    (rnrs sorting (6)) procedure (vector-sort! (< procedure?) (v vector?) ) ⟹ boolean?

    (< obj1 obj2 ) ⟹ boolean?

    Proc should accept any two elements of the vector, and should not have any side effects. Proc should return a true value when its first argument is strictly less than its second, and #f otherwise. The vector-sort! procedure destructively sorts vector in ascending order according to proc. The sorting algorithm performs O(n2) calls to proc where n is the length of vector, and all arguments passed to proc are elements of the vector being sorted, but the pairing of arguments and the sequencing of calls to proc are not specified. The sorting algorithm may be unstable. The procedure returns unspecified values.

    library (rnrs unicode (6))

    (rnrs unicode (6)) procedure (char-upcase (char char?) ) ⟹ char?

    (rnrs unicode (6)) procedure (char-downcase (char char?) ) ⟹ char?

    (rnrs unicode (6)) procedure (char-titlecase (char char?) ) ⟹ char?

    (rnrs unicode (6)) procedure (char-foldcase (char char?) ) ⟹ char?

    These procedures take a character argument and return a character result. If the argument is an upper-case or title-case character, and if there is a single character that is its lower-case form, then char-downcase returns that character. If the argument is a lower-case or title-case character, and there is a single character that is its upper-case form, then char-upcase returns that character. If the argument is a lower-case or upper-case character, and there is a single character that is its title-case form, then char-titlecase returns that character. If the argument is not a title-case character and there is no single character that is its title-case form, then char-titlecase returns the upper-case form of the argument. Finally, if the character has a case-folded character, then char-foldcase returns that character. Otherwise the character returned is the same as the argument. For Turkic characters İ (#\x130) and ı (#\x131), char-foldcase behaves as the identity function; otherwise char-foldcase is the same as char-downcase composed with char-upcase.

    (rnrs unicode (6)) procedure (char-ci<=? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

    (rnrs unicode (6)) procedure (char-ci<? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

    (rnrs unicode (6)) procedure (char-ci=? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

    (rnrs unicode (6)) procedure (char-ci>=? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

    (rnrs unicode (6)) procedure (char-ci>? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

    These procedures are similar to char=?, etc., but operate on the case-folded versions of the characters.

    (rnrs unicode (6)) procedure (char-alphabetic? (char char?) ) ⟹ boolean?

    (rnrs unicode (6)) procedure (char-numeric? (char char?) ) ⟹ boolean?

    (rnrs unicode (6)) procedure (char-whitespace? (char char?) ) ⟹ boolean?

    (rnrs unicode (6)) procedure (char-upper-case? (char char?) ) ⟹ boolean?

    (rnrs unicode (6)) procedure (char-lower-case? (char char?) ) ⟹ boolean?

    (rnrs unicode (6)) procedure (char-title-case? (char char?) ) ⟹ boolean?

    These procedures return #t if their arguments are alphabetic, numeric, whitespace, upper-case, lower-case, or title-case characters, respectively; otherwise they return #f.

    A character is alphabetic if it has the Unicode "Alphabetic" property. A character is numeric if it has the Unicode "Numeric" property. A character is whitespace if has the Unicode "White_Space" property. A character is upper case if it has the Unicode "Uppercase" property, lower case if it has the "Lowercase" property, and title case if it is in the Lt general category.

    (rnrs unicode (6)) procedure (char-general-category (char char?) ) ⟹ symbol?

    Returns a symbol representing the Unicode general category of char, one of Lu, Ll, Lt, Lm, Lo, Mn, Mc, Me, Nd, Nl, No, Ps, Pe, Pi, Pf, Pd, Pc, Po, Sc, Sm, Sk, So, Zs, Zp, Zl, Cc, Cf, Cs, Co, or Cn.

    (rnrs unicode (6)) procedure (string-upcase (string string?) ) ⟹ string?

    (rnrs unicode (6)) procedure (string-downcase (string string?) ) ⟹ string?

    (rnrs unicode (6)) procedure (string-titlecase (string string?) ) ⟹ string?

    (rnrs unicode (6)) procedure (string-foldcase (string string?) ) ⟹ string?

    These procedures take a string argument and return a string result. They are defined in terms of Unicode's locale-independent case mappings from Unicode scalar-value sequences to scalar-value sequences. In particular, the length of the result string can be different from the length of the input string. When the specified result is equal in the sense of string=? to the argument, these procedures may return the argument instead of a newly allocated string.

    The string-upcase procedure converts a string to upper case; string-downcase converts a string to lower case. The string-foldcase procedure converts the string to its case-folded counterpart, using the full case-folding mapping, but without the special mappings for Turkic languages. The string-titlecase procedure converts the first cased character of each word via char-titlecase, and downcases all other cased characters.

    (rnrs unicode (6)) procedure (string-ci<=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?

    (rnrs unicode (6)) procedure (string-ci<? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?

    (rnrs unicode (6)) procedure (string-ci=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?

    (rnrs unicode (6)) procedure (string-ci>=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?

    (rnrs unicode (6)) procedure (string-ci>? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?

    These procedures are similar to string=?, etc., but operate on the case-folded versions of the strings.

    (rnrs unicode (6)) procedure (string-normalize-nfd (string string?) ) ⟹ string?

    (rnrs unicode (6)) procedure (string-normalize-nfkd (string string?) ) ⟹ string?

    (rnrs unicode (6)) procedure (string-normalize-nfc (string string?) ) ⟹ string?

    (rnrs unicode (6)) procedure (string-normalize-nfkc (string string?) ) ⟹ string?

    These procedures take a string argument and return a string result, which is the input string normalized to Unicode normalization form D, KD, C, or KC, respectively. When the specified result is equal in the sense of string=? to the argument, these procedures may return the argument instead of a newly allocated string.