5.92
3 Class 1
#lang class/1 | package: base |
syntax
(require module-name ...)
Imports all the modules named module-names.
syntax
(define-class class-name super-spec fields-spec method-spec ...)
super-spec =
| (super super-name) fields-spec =
| (fields field-name ...) method-spec =
(define (method-name arg ...) body)
Defines a new class named class-name, much like as with
class/0, however a class may declare super-name
as a super class of class-name by using (super super-name).
When a class definition declares a super class, it inherits all of the super class’s fields and methods. The constructor for the class takes values for its fields followed by values for the fields of the super class.
> (define-class c% (fields x) (define (m) 'm!))
> (define-class d% (super c%) (fields y) (define (n) 'n!))
> (define d (new d% 'y! 'x!))
> (send d m) 'm!
> (send d n) 'n!
> (send d x) 'x!
> (send d y) 'y!
syntax
(super class-name)
See define-class.
syntax
syntax
(fields id ...)
syntax
(define (method-name id ...) body)
syntax
(new class-name arg ...)
syntax
syntax
(send object message arg ...)
These have the same meaning as in class/0.
syntax