Next: , Previous: , Up: scheme entry   [Index]


3.6.2 Procedure entries

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:

Procedure: vector-ref vector k

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:

Procedure: procname k

Procedure: procname k fill

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:

Procedure: the-proc z1 z2 z3 ...

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:

obj

any object;

z

complex number object;

x

real number object;

y

real number object;

q

rational number object;

n

integer object;

k

exact non–negative integer object;

bool

boolean (#f or #t);

octet

exact integer object in {0, …, 255};

byte

exact integer object in {-128, …, 127};

char

character;

pair

pair;

vector

vector;

string

string;

condition

condition;

bytevector

bytevector;

proc

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: , Previous: , Up: scheme entry   [Index]