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

12 The Built-In Functions

Reflective Operations on Functions

generic-function-methods [Function]


Returns the methods of a generic function.

Signature:
generic-function-methods generic-function Þ sequence

Arguments:
generic-function
An instance of <generic-function>.

Values:
sequence An instance of <sequence>. Each element in the sequence is an instance of <method>.

Description:
Returns a sequence of all of the methods in generic-function. The order of the methods in the sequence is not significant. The sequence returned should never be destructively modified. Doing so may cause unpredictable behavior.

If generic-function is sealed, an implementation may choose not to return a sequence of methods, but instead signal an error of type <sealed-object-error>.

add-method [Function]


Adds a method to a generic function.

Signature:
add-method generic-function method Þ new-method old-method

Arguments:
generic-function
An instance of <generic-function>.

method
An instance of <method>.

Values:
new-method An instance of <method>.

old-method
#f or an instance of <method>.

Description:
Adds method to generic-function, thereby modifying the generic-function.

Programs do not commonly call add-method directly. It is called by define method.

If you add a method to a generic function, and the generic function already has a method with the exact same specializers, then the old method is replaced with the new one.

A single method may be added to any number of generic functions.

add-method returns two values. The first is the new method. The second will be either the method in generic-function which is being replaced by method, or it will be #f if no method is being replaced.

add-method may signal an error of type <sealed-object-error> if adding the method or replacing an existing method would cause a sealing violation.

generic-function-mandatory-keywords [Function]


Returns the mandatory keywords of a generic function, if any.

Signature:
generic-function-mandatory-keywords generic-function Þ keywords

Arguments:
generic-function
An instance of <generic-function>.

Values:
keywords The object #f or an instance of <collection>.

Description:
If generic-function accepts keyword arguments, returns a collection of the mandatory keywords for generic-function. This collection will be empty if the generic function accepts keywords but does not have any mandatory keywords. It returns #f if generic-function does not accept keyword arguments.

The collection returned should never be destructively modified. Doing so may cause unpredictable behavior.

function-specializers [Function]


Returns the specializers of a function.

Signature:
function-specializers function Þ sequence

Arguments:
function An instance of <function>.

Values:
sequence An instance of <sequence>. The elements of the sequence are instances of <type>.

Description:
Returns a sequence of the specializers for function. The length of the sequence will equal the number of required arguments of function. The first element of the sequence will be the specializer of the first argument of function, the second will be the specializer of the second argument, etc.

The sequence returned should never be destructively modified. Doing so may cause unpredictable behavior.

function-arguments [Function]


Returns information about the arguments accepted by a function.

Signature:
function-arguments function Þ required-number rest-boolean kwd-sequence

Arguments:
function An instance of <function>.

Values:
required-number
An instance of <integer>.

rest-boolean
An instance of <boolean>.

kwd-sequence

Either #f or the symbol #"all" or an instance of <collection> whose elements are instances of <keyword>.

Description:
Returns three values:

function-return-values [Function]


Returns information about the values returned by a function.

Signature:
function-return-values function Þ return-value-types rest-return-value

Arguments:
function An instance of <function>.

Values:
return-value-types
An instance of <sequence>. The elements of the sequence are instances of <type>.

rest-return-value
An instance of <type> or #f.

Description:
Returns two values:

applicable-method? [Function]


Tests if a function is applicable to sample arguments.

Signature:
applicable-method? function #rest sample-arguments Þ boolean

Arguments:
function An instance of <function>.

sample-arguments
Instances of <object>.

Values:
boolean An instance of <boolean>.

Description:
Returns true if function is a method or contains a method that would be applicable to sample-arguments.

sorted-applicable-methods [Function]


Returns all the methods in a generic function that are applicable to sample arguments, sorted in order of specificity.

Signature:
sorted-applicable-methods generic-function #rest sample-arguments
Þ sorted-methods unsorted-methods

Arguments:
generic-function
An instance of <generic-function>.

sample-arguments
Instances of <object>.

Values:
sorted-methods
An instance of <sequence>. Elements of the sequence are instances of <method>.

unsorted-methods
An instance of <sequence>. Elements of the collection are instances of <method>.

Description:
Returns two sequences that, taken together, contain the methods in generic-function that are applicable to the sample-arguments. sorted-methods contains methods that are more specific than every method that follows them. unsorted-methods begins at the first point of ambiguity; it contains the methods that cannot be sorted.

The sequences returned should never be destructively modified. Doing so may cause unpredictable behavior.

find-method [Function]


Returns the method in a generic function that has particular specializers.

Signature:
find-method generic-function specializers Þ found-method

Arguments:
generic-function
An instance of <generic-function>.

specializers
An instance of <sequence>. Elements of the sequence are instances of <type>.

Values:
found-method #f or an instance of <method>.

Description:
Returns the method in generic-function that has the specializers in specializers as its specializers. The specializers must match exactly for a method to be returned.

If generic-function is sealed, an implementation may choose to signal an error of type <sealed-object-error> rather than return a value.

remove-method [Function]


Removes a method from a generic function.

Signature:
remove-method generic-function method Þ method

Arguments:
generic-function
An instance of <generic-function>.

method
An instance of <method>.

Values:
method An instance of <method>.

Description:
Removes method from generic-function and returns method.

This operation modifies the generic-function.

remove-method will signal an error if method is not in generic-function. If generic-function is sealed, or if method is in an inert domain of generic-function , then an error of type <sealed-object-error> is signaled.


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

Generated with Harlequin WebMaker