Classes with defined Methods: classd.ss

Next: Command-line Parsing: cmdline.ss Up: MzLib Libraries Previous: Awk: awk.ss

## Classes with `define`d Methods: `classd.ss`

Files: `classd.ss`
Requires: `refer.ss`

The `class/d` macro provides a syntax for class expressions that uses `define`-style syntax to bind instance variables, instead of the `letrec`-style syntax of `class`: ``

      (class/d superclass-expr initialization-variables
         (variable-spec-clause   )
         definition-or-expression
           )

      variable-spec-clause is one of:
         (public variable ...)
         (override variable ...)
         (inherit variable ...)
         (rename (variable variable) ...)

The superclass-expr and initialization-variables have the same form as in a `class` expression.

Each definition-or-expression is either an expression or a definition using `define`, `#%define`, `define-values`, `#%define-values`, `define-struct`, or `#%define-struct`. The set of recognized definition forms is fixed; macro expressions that expand to `define`, for example, are not recognized as definition. No variable can be defined more than once.

A `public` or `override` variable-spec-clause indicates that the definitions (in the definition-or-expressions) for the corresponding variables in bind instance variables. Defined variables that are not mentioned in any `public` or `override` clause create private instance variables. An `inherit` or `rename` clause binds variables to inherited and renamed instance variables (and cannot be redefined in any definition-or-expression).

The definition-or-expressions are evaluated in the order in which they are specified. A definition for an instance variable sets the variable's value immediately, so that calls to methods in the object see the installed value. Prior to its definition, the value of a declared `public` or `override` instance variable is the undefined value, as for `class`.

The `class/d*` and `class/d*/names` forms implement `define`-based analogues of `class*` and `class*/names`: ``

      (class/d* superclass-expr (interface-expr   ) initialization-variables
         (variable-spec-clause   )
         definition-or-expression
           )
      (class/d*/names local-names superclass-expr (interface-expr   ) initialization-variables
         (variable-spec-clause   )
         definition-or-expression
           )