DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(goops.info.gz) Basic Class Definition

Info Catalog (goops.info.gz) Defining New Classes (goops.info.gz) Class Options
 
 Basic Class Definition
 ----------------------
 
 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.
 
  - syntax: define-class name (super ...) slot-definition ... . options
      Define a class called NAME that inherits from SUPERs, with direct
      slots defined by SLOT-DEFINITIONs and class options OPTIONS.  The
      newly created class is bound to the variable name NAME in the
      current environment.
 
      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  Class Options and  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 `side-length' and `num-sides'.
 
      (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>)
 
Info Catalog (goops.info.gz) Defining New Classes (goops.info.gz) Class Options
automatically generated byinfo2html