Warning: This is the manual of the legacy Guile 2.0 series. You may want to read the manual of the current stable series instead.

Next: , Up: Methods and Generic Functions   [Contents][Index]

8.6.1 Accessors

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.

syntax: define-accessor symbol

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.