Functions are the objects that accept arguments, perform computations, and return values.
Figure 11-5 shows the built-in function classes and some of their characteristics.
Figure 11-5 The Function Classes
| S | – Sealed | P | – Primary | C | – Concrete | I | – Instantiable |
| O | – Open | F | – Free | A | – Abstract | U | – Uninstantiable |
<function> [Sealed Abstract Class]The class of objects that can be applied to arguments.
<object>
None.
All functions are instances of <function>. Functions are described in Chapter 6, "Functions."
The class <function> provides the following operations:
<generic-function> [Sealed Instantiable Class]The class of functions that are made up of a number of individual methods.
<function>
The class <generic-function> supports the following init-keywords:
required: An instance of <number> or <sequence>.
This argument represents the required arguments that the generic function accepts. If a sequence is supplied, the size of the sequence is the number of required arguments, and the elements of the sequence are the specializers. If a number is supplied, it is the number of required arguments, and the specializers default to <object>. If the argument is not supplied, or the supplied argument is neither a sequence nor a non-negative integer, an error is signaled.
rest?: An instance of <boolean>.
A true value indicates that the generic function accepts a variable number of arguments. The default value is #f.
key: #f or an instance of <collection> whose elements are keywords.
If the value is a collection, then the generic function accepts keyword arguments, and the collection specifies the set of mandatory keywords for the generic function. A value of #f indicates that the generic function does not accept keyword arguments. The default value is #f.
all-keys?: An instance of <boolean>.
A true value indicates that the generic function accepts all keyword arguments. The default value is #f.
The class of generic functions. Generic functions are described in Chapter 6, "Functions."
The arguments describe the shape of the generic function's parameter list, and thereby control which methods can be added to the generic function. See the section "Kinds of Parameter Lists" on page 86 and the section "Parameter List Congruency" on page 93 for the implications of these choices.
An error is signaled if the value of rest?: is true and the value of key: is a collection. While a method parameter list may specify both #rest and #key, a generic function parameter list cannot.
An error is signaled if the value of all-keys?: is true and the value of key: is #f.
A new generic function initially has no methods. An error will be signaled if a generic function is called before methods are added to it. Once a generic function is created, you can give it behavior by adding methods to it with add-method or define method.
Generic functions are not usually created by calling make directly. Most often they are created by define generic or implicitly by define method.
Operations: The class <generic-function> provides the following operations:
Function |
| Description | Page |
|---|---|---|---|
|
| ||
|
| ||
|
| Returns the mandatory keywords of a generic function, if any. | |
|
| ||
|
| Returns the method in a generic function that has particular specializers. | |
|
|
<method> [Sealed Class]The class of functions that are applicable to arguments of a specified type.
<function>
None.
The class of methods. Methods are described in Chapter 6, "Functions."
The class <method> provides the following operations:
Function |
| Description | Page |
|---|---|---|---|
|
| ||
|
|