Chapter 11
The Built-In Classes
Functions
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 |
General Functions
<function>
[Sealed Abstract Class]
The class of objects that can be applied to arguments.
- Superclasses:
<object>
- Init-keywords:
None.
- Description:
All functions are instances of
<function>
. Functions are described in Chapter 6,Functions.
- Operations:
-
The class
<function>
provides the following operations:
Generic Functions
<generic-function>
[Sealed Instantiable Class]
The class of functions that are made up of a number of individual methods.
- Superclasses:
<function>
- Init-keywords:
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.
- Description:
-
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 sectionParameter 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 ofkey:
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 ofkey:
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
ordefine method
.Generic functions are not usually created by calling
make
directly. Most often they are created bydefine generic
or implicitly bydefine method
. - Operations:
-
The class
<generic-function>
provides the following operations:Table 11-66 Functions on <generic-function> Function
Description
Page
generic-function-methods
add-method
generic-function-mandatory-keywords
Returns the mandatory keywords of a generic function, if any.
sorted-applicable-methods
find-method
Returns the method in a generic function that has particular specializers.
remove-method
Methods
<method>
[Sealed Class]
The class of functions that are applicable to arguments of a specified type.
- Superclasses:
<function>
- Init-keywords:
None.
- Description:
The class of methods. Methods are described in Chapter 6,
Functions.
- Operations:
-
The class
<method>
provides the following operations:Table 11-67 Functions on <method> Function
Description
Page
add-method
remove-method