Next: Extending Primitives, Up: Methods and Generic Functions [Contents][Index]
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! (accessor
args
…)value
)
by calling the most specialized method of accessor
that matches
the classes of args
and value
. define-accessor
is
used to bind an identifier to an accessor.
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.