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:
mixin
Version: 4.0.2

 

5.5 Mixins

(mixin (interface-expr ...) (interface-expr ...)

  class-clause ...)

Produces a mixin, which is a procedure that encapsulates a class extension, leaving the superclass unspecified. Each time that a mixin is applied to a specific superclass, it produces a new derived class using the encapsulated extension.

The given class must implement interfaces produced by the first set of interface-exprs. The result of the procedure is a subclass of the given class that implements the interfaces produced by the second set of interface-exprs. The class-clauses are as for class*, to define the class extension encapsulated by the mixin.

Evaluation of a mixin form checks that the class-clauses are consistent with both sets of interface-exprs.