Entry format

Chapters 4 and 6 are organized into entries. Each entry describes one language feature or a group of related features, where a feature is either a syntactic construct or a procedure. An entry begins with one or more header lines of the form

template category

for identifiers in the base library, or

template name library category

where name is the short name of a library as defined in Appendix A.

If category is "syntax," the entry describes an expression type, and the template gives the syntax of the expression type. Components of expressions are designated by syntactic variables, which are written using brackets, for example {expression} and {variable}. Syntactic variables are intended to denote segments of program text; for example, expression stands for any string of characters which is a syntactically valid expression. The notation

{thing} ...

indicates zero or more occurrences of a thing, and

{thing1} {thing2} ...

indicates one or more occurrences of a thing.

If category is "auxiliary syntax," then the entry describes a syntax binding that occurs only as part of specific surrounding expressions. Any use as an independent syntactic construct or variable is an error.

If category is "special form," then the entry describes an expression type that is built directly into the Husk interpreter.

If category is "procedure," then the entry describes a procedure, and the header line gives a template for a call to the procedure. Thus the header line

(vector-ref vector k ) procedure

indicates that the procedure bound to the vector-ref variable takes two arguments, a vector vector and an exact non-negative integer k (see below). The header lines

(make-vector k ) procedure
(make-vector k fill ) procedure

indicate that the make-vector procedure must be defined to take either one or two arguments.

It is an error for a procedure to be presented with an argument that it is not specified to handle. For succinctness, we follow the convention that if an argument name is also the name of a type listed in section 3.2, then it is an error if that argument is not of the named type. For example, the header line for vector-ref given above dictates that the first argument to vector-ref is a vector. The following naming conventions also imply type restrictions:

alist association list (list of pairs) boolean boolean value (#t or #f) byte exact integer 0 byte < 256 bytevector bytevector char character end exact non-negative integer k, k1, ... kj , ... exact non-negative integer letter alphabetic character list, list1, ... listj , ... list (see section 6.4) n, n1, ... nj , ... integer obj any object pair pair port port proc procedure q, q1, ... qj , ... rational number start exact non-negative integer string string symbol symbol thunk zero-argument procedure vector vector x, x1, ... xj , ... real number y, y1, ... yj , ... real number z, z1, ... zj , ... complex number

The names start and end are used as indexes into strings, vectors, and bytevectors. Their use implies the following:

  • It is an error if start is greater than end.
  • It is an error if end is greater than the length of the string, vector, or bytevector.
  • If start is omitted, it is assumed to be zero.
  • If end is omitted, it assumed to be the length of the string, vector, or bytevector.
  • The index start is always inclusive and the index end is always exclusive. As an example, consider a string. If start and end are the same, an empty substring is referred to, and if start is zero and end is the length of string, then the entire string is referred to.

husk-scheme online documentation rev 3.2 (2021.03.04)