Functions: pre-defining

Function pre-definitions

  • allow function interfaces to be described separately from function implementations and
  • support mutually recursive functions.

Functions must be defined or pre-defined before they are used. For mutually recursive functions, one or more of the functions must be pre-defined prior to the first actual function definition. A pre-definition looks like a function definition with no body:

  define function sort-by-value read-only stream original
                  into          modifiable  stream sorted
                  elsewhere

In general the properties of the function arguments in a predefinition must match those in the function definition. The exceptions are:

  • The argument names in elsewhere definitions are placeholders. The arguments can have different names when the function is defined.
  • The predefinition should not specify initial values for the optional arguments. The initial values should only be specified in the function definition. (Initial values are permitted in the predefinition for backwards compatibility (if the values are static, not dynamic), but this is discouraged.)

Prerequisite Concepts