Next: scheme entry implementation resp, Previous: scheme entry syntax, Up: scheme entry [Index]
If Category is “Procedure”, then the entry describes a procedure, and the header line gives a template for a call to the procedure. Parameter names in the template are shown like this: parm. Thus the header line:
…
indicates that the built–in procedure vector-ref
takes two
arguments, a vector vector and an exact non–negative integer
object k (see below). The header lines:
…
…
indicate that the make-vector
procedure takes either one or two
arguments. The parameter names are case–insensitive.
As with syntax templates, an ellipsis … at the end of a header line, as in:
…
indicates that the procedure takes arbitrarily many arguments of the
same type as specified for the last parameter name. In this case,
=
accepts two or more arguments that must all be complex number
objects.
A procedure that detects an argument that it is not specified to handle
must raise an exception with condition type &assertion
. Also,
the argument specifications are exhaustive: if the number of arguments
provided in a procedure call does not match any number of arguments
accepted by the procedure, an exception with condition type
&assertion
must be raised.
For succinctness, the report follows the convention that if a parameter
name is also the name of a type, then the corresponding argument must be
of the named type. For example, the header line for vector-ref
given above dictates that the first argument to vector-ref
must
be a vector. The following naming conventions imply type restrictions:
any object;
complex number object;
real number object;
real number object;
rational number object;
integer object;
exact non–negative integer object;
boolean (#f
or #t
);
exact integer object in {0, …, 255};
exact integer object in {-128, …, 127};
character;
pair;
vector;
string;
condition;
bytevector;
procedure.
Other type restrictions are expressed through parameter–naming conventions that are described in specific chapters. For example, library chapter “Arithmetic” uses a number of special parameter variables for the various subsets of the numbers.
With the listed type restrictions, it is the programmer’s responsibility to ensure that the corresponding argument is of the specified type. It is the implementation’s responsibility to check for that type.
A parameter called list means that it is the programmer’s responsibility to pass an argument that is a list. It is the implementation’s responsibility to check that the argument is appropriately structured for the operation to perform its function, to the extent that this is possible and reasonable. The implementation must at least check that the argument is either an empty list or a pair.
Descriptions of procedures may express other restrictions on the arguments of a procedure. Typically, such a restriction is formulated as a phrase of the form “x must be a …” (or otherwise using the word “must”).
Next: scheme entry implementation resp, Previous: scheme entry syntax, Up: scheme entry [Index]