A generic function is a collection of methods, with rules for
determining which of the methods should be applied for any given
invocation of the generic function. GOOPS represents generic functions
as metaobjects of the class <generic> (or one of its subclasses).
An accessor is a generic function that can also be used with the
generalized set! syntax (see Procedures with Setters). Guile
will handle a call like
(set! (accessorargs...)value)
by calling the most specialized method of accessor that matches
the classes of args and value.
The following forms define a variable as a generic function or accessor. Depending on that variable's previous value, the generic function may be created empty — with no methods — or with methods that are inferred from the previous value.
Create a generic function with name symbol and bind it to the variable symbol. If symbol was previously bound to a Scheme procedure (or procedure-with-setter), the old procedure (and setter) is incorporated into the new generic function as its default procedure (and setter). Any other previous value, including an existing generic function, is discarded and replaced by a new, empty generic function.
Create an accessor with name symbol and bind it to the variable symbol. If symbol was previously bound to a Scheme procedure (or procedure-with-setter), the old procedure (and setter) is incorporated into the new accessor as its default procedure (and setter). Any other previous value, including an existing generic function or accessor, is discarded and replaced by a new, empty accessor.