On this page:
require
provide
class
define-class
set-field!
super
implements
name
constructor
this
fields
define/ public
new
field
send
define-interface
Version: 5.3.0.1

7 Class 5

 #lang class/5

(require module-name ...)
Imports all the modules named module-names.

(provide id ...)
Makes all of the ids available to other modules.

(class
  name-spec
  super-spec
  implements-spec
  fields-spec
  constructor-spec
  method/test-spec ...)
 
name-spec = 
  | (name class-name)
     
super-spec = 
  | (super super-expr super-interface-name)
     
implements-spec = 
  | (implements interface-name ...)
     
fields-spec = 
  | (fields field-name ...)
     
constructor-spec = 
  | (constructor (arg ...) body ...)
     
method-spec = 
(define/public (method-name arg ...)
  body)
  | (check-expect actual expected)
Defines a class value. Inherits the methods and fields specified in super-interface-name, and is a subclass of the class that super-expr evaluates to.

(define-class class-name body-forms ...)
The same as (define class-name (class (name class-name) body-forms ...)).

(set-field! f e)
Changes the value of field f to be the result of e.

(super class-or-interface-name)
(implements interface-name ...)
(name class-name)
(constructor (args ...) body)

this
(fields id ...)
(define/public (method-name id ...) body)
(new class-name arg ...)
(field field-name)
(send object message arg ...)
These have the same meaning as in class/0.

(define-interface interface-name
  (super super-interface) ...
  (method-name ...)
  (field-name ...))
Describes a class with the given methods and fields.

}