2.7 Invoking Generic Functions
When a variable with a generic function definition appears as the first
element of a list that is being evaluated, the Guile evaluator tries
to apply the generic function to the arguments obtained by evaluating
the remaining elements of the list. [ *fixme* How do I put this in a
more Schemely and less Lispy way? ]
Usually a generic function contains several method definitions, with
varying degrees of formal parameter specialization (see section define-method). So it is necessary to sort these
methods by specificity with respect to the supplied arguments, and then
apply the most specific method definition. Less specific methods
may be applied subsequently if a method that is being applied calls
next-method.
2.7.1 Determining Which Methods to Apply
[ *fixme* Sorry - this is the area of GOOPS that I understand least of
all, so I'm afraid I have to pass on this section. Would some other
kind person consider filling it in? ]
- generic: apply-generic
-
- method: apply-generic (gf <generic>) args
- generic: compute-applicable-methods
-
- method: compute-applicable-methods (gf <generic>) args
- generic: sort-applicable-methods
-
- method: sort-applicable-methods (gf <generic>) methods args
- generic: method-more-specific?
-
- method: method-more-specific? (m1 <method>) (m2 <method>) args
- generic: apply-method
-
- method: apply-method (gf <generic>) methods build-next args
- generic: apply-methods
-
- method: apply-methods (gf <generic>) (l <list>) args
2.7.2 Handling Invocation Errors
- generic: no-method
-
- method: no-method (gf <generic>) args
- When an application invokes a generic function, and no methods at all
have been defined for that generic function, GOOPS calls the
no-method generic function. The default method calls
goops-error with an appropriate message.
- generic: no-applicable-method
-
- method: no-applicable-method (gf <generic>) args
- When an application applies a generic function to a set of arguments,
and no methods have been defined for those argument types, GOOPS calls
the
no-applicable-method generic function. The default method
calls goops-error with an appropriate message.
- generic: no-next-method
-
- method: no-next-method (gf <generic>) args
- When a generic function method calls
(next-method) to invoke the
next less specialized method for that generic function, and no less
specialized methods have been defined for the current generic function
arguments, GOOPS calls the no-next-method generic function. The
default method calls goops-error with an appropriate message.
This document was generated
by Ingo Ruhnke on September, 12 2002
using texi2html