Goops Manual (original) (raw)
Node:Method Definition Internals, Previous:Basic Method Definition, Up:Adding Methods to Generic Functions
3.6.2 Method Definition Internals
define-method
- checks the form of the first parameter, and applies the following steps to the accessor's setter if it has the
(setter ...)
form - interpolates a call to
define-generic
ordefine-accessor
if a generic function is not already defined with the supplied name - calls
method
with the parameters and body, to make a new method instance - calls
add-method!
to add this method to the relevant generic function.
method (parameter ...) . body | syntax |
---|
Make a method whose specializers are defined by the classes inparameters and whose procedure definition is constructed from theparameter symbols and body forms.
The parameter and body parameters should be as fordefine-method
(see define-method).
method
- extracts formals and specializing classes from the parameters, defaulting the class for unspecialized parameters to
<top>
- creates a closure using the formals and the body forms
- calls
make
with metaclass<method>
and the specializers and closure using the#:specializers
and#:procedure
keywords.
make-method specializers procedure | procedure |
---|
Make a method using specializers and procedure.
specializers should be a list of classes that specifies the parameter combinations to which this method will be applicable.
procedure should be the closure that will applied to the generic function parameters when this method is invoked.
make-method
is a simple wrapper around make
with metaclass<method>
.
add-method! target method | generic |
---|
Generic function for adding method method to target.
add-method! (generic ) (method ) | method |
---|
Add method method to the generic function generic.
add-method! (proc ) (method ) | method |
---|
If proc is a procedure with generic capability (see generic-capability?), upgrade it to a primitive generic and add method to its generic function definition.
add-method! (pg ) (method ) | method |
---|
Add method method to the generic function definition of pg.
Implementation: (add-method! (primitive-generic-generic pg) method)
.
add-method! (whatever ) (method ) | method |
---|
Raise an error indicating that whatever is not a valid generic function.