Buy GNU books!
|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]||[Top]||[Contents]||[Index]||[ ? ]|
New classes are defined using the
define-class syntax, with
arguments that specify the classes that the new class should inherit
from, the direct slots of the new class, and any required class options.
Each slot-definition is either a symbol that names the slot or a list,
(slot-name-symbol . slot-options)
where slot-name-symbol is a symbol and slot-options is a list with an even number of elements. The even-numbered elements of slot-options (counting from zero) are slot option keywords; the odd-numbered elements are the corresponding values for those keywords.
options is a similarly structured list containing class option keywords and corresponding values.
The standard GOOPS class and slot options are described in the following subsections: see 3.2.2 Class Options and 3.2.3 Slot Options.
Example 1. Define a class that combines two pre-existing classes by inheritance but adds no new slots.
(define-class <combined> (<tree> <bicycle>))
Example 2. Define a
regular-polygon class with slots for side
length and number of sides that have default values and can be accessed
via the generic functions
(define-class <regular-polygon> () (sl #:init-value 1 #:accessor side-length) (ns #:init-value 5 #:accessor num-sides))
Example 3. Define a class whose behavior (and that of its instances) is customized via an application-defined metaclass.
(define-class <tcpip-fsm> () (s #:init-value #f #:accessor state) ... #:metaclass <finite-state-class>)
|webmaster||delorie software privacy|
|Copyright © 2003 by The Free Software Foundation||Updated Jun 2003|