1 Language Model
2 Syntactic Forms
3 Datatypes
4 Structures
5 Classes and Objects
6 Units
7 Contracts
8 Pattern Matching
9 Control Flow
10 Concurrency
11 Macros
12 Input and Output
13 Reflection and Security
14 Operating System
15 Memory Management
16 Running PLT Scheme
Bibliography
Index
On this page:
interface
Version: 4.0.2

 

5.1 Creating Interfaces

(interface (super-interface-expr ...) id ...)

Produces an interface. The ids must be mutually 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:fail: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 ids, plus all identifiers from the superinterfaces. Duplicate identifier names among the superinterfaces are ignored, but if a superinterface contains one of the ids in the interface expression, the exn:fail: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:fail:object exception is raised.