Next: Creating Classes Up: Classes and Objects Previous: Object Example

# Creating Interfaces

The `interface` form creates a new interface: ``

      (interface (super-interface-expr   ) variable   )

All of the variables must be distinct.

Each super-interface-expr is evaluated (in order) when the `interface` expression is evaluated. The result of each super-interface-expr must be an interface value, otherwise the `exn:object` exception is raised. The interfaces returned by the super-interface-exprs are the new interface's superinterfaces, which are all extended by the new interface. Any class that implements the new interface also implements all of the superinterfaces.

The result of an `interface` expression is an interface that includes all of the specified variables, plus all variables from the superinterfaces. Duplicate variable names among the superinterfaces are ignored, but if a superinteface contains one of the variables in the `interface` expression, the `exn:object` exception is raised.

If no super-interface-exprs are provided, then the derivation requirement of the resulting interface is trivial: any class that implements the interface must be derived from `object%`. Otherwise, the implementation requirement of the resulting interface is the most specific requirement from its superinterfaces. If the superinterfaces specify inconsistent derivation requirements, the `exn:object` exception is raised.