[Next] [Previous] [Up] [Top] [Contents] [Index]

11 The Built-In Classes

Functions

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:
Functions on <function> (continued)
Function DescriptionPage
compose Returns the composition of one or more functions.332
complement Returns a function that expresses the complement of a predicate.333
disjoin Returns a function that expresses the disjunction of one or more predicates.333
conjoin Returns a function that expresses the conjunction of one or more predicates.334
curry Returns a function based on an existing function and a number of default initial arguments.334
rcurry Returns a function based on an existing function and a number of default final arguments.335
function-specializers Returns the specializers of a function.339
function-arguments Returns information about the arguments accepted by a function.340
function-return-values Returns information about the values returned by a function.341
applicable-method? Tests if a function is applicable to sample arguments.341
apply Applies a function to arguments.337
do Iterates over one or more collections for side effect.313
map Iterates over one or more collections and collects the results in a freshly allocated collection.314
map-as Iterates over one or more collections and collects the results in a freshly allocated collection of a specified type.314
map-into Iterates over one or more collections and collects the results in an existing mutable collection.315
any? Returns the first true value obtained by iterating over one or more collections.316
every? Returns true if a predicate returns true when applied to all corresponding elements of a set of collections.317
reduce Combines the elements of a collection and a seed value into a single value by repeatedly applying a binary function.318
reduce1 Combines the elements of a collection into a single value by repeatedly applying a binary function, using the first element of the collection as the seed value.319
find-key Returns the key in a collection such that the corresponding collection element satisfies a predicate.321
replace-elements! Replaces collection elements that satisfy a predicate.322
choose Returns those elements of a sequence that satisfy a predicate.319
choose-by Returns those elements of a sequence that correspond to those in another sequence that satisfy a predicate.320
do-handlers Applies a function to all dynamically active handlers.349

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 84 and the section "Parameter List Congruency" on page 91 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 addmethod 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:
Functions on <generic-function> (continued)
Function DescriptionPage
generic-function-
methods
 Returns the methods of a generic function.338
add-method Adds a method to a generic function.338
generic-function-
mandatory-keywords
 Returns the mandatory keywords of a generic function, if any.339
sorted-applicable-methods Returns all the methods in a generic function that are applicable to sample arguments, sorted in order of specificity.342
find-method Returns the method in a generic function that has particular specializers.343
remove-method Removes a method from a generic function.343

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:
Functions on <method> (continued)
Function DescriptionPage
add-method Adds a method to a generic function.338
remove-method Removes a method from a generic function.343


Dylan Reference Manual - 17 OCT 1995
[Next] [Previous] [Up] [Top] [Contents] [Index]

Generated with Harlequin WebMaker