Anonymous classes

Syntax: object (supers ...) field-or-method-decl ...

Returns a new instance of an anonymous (inner) class. The syntax is similar to define-class.


field-or-method ::= field-decl | method-decl
field-decl ::= (fname [[[::] ftypefinit])
    | (fname [:: ftype] [option-keyword option-value]*)
method-decl ::= ((method-name formal-arguments) [[::] rtypebody)

Returns a new instance of a unique (anonymous) class. The class inherits from the list of supers, where at most one of the elements should be the base class being extended from, and the rest are interfaces.

This is roughly equivalent to:

(begin
  (define-simple-class hname (supers ...) field-or-method-decl ...)
  (make hname))

A field-decl is as for define-class, except that we also allow an abbreviated syntax. Each field-decl declares a public instance field. If ftype is given, it specifies the type of the field. If finit is given, it is an expression whose value becomes the initial value of the field. The finit is evaluated at the same time as the object expression is evaluated, in a scope where all the fnames are visible.

A method-decl is as for define-class.