Online Manual: Compound Classages

Classages allows programmers to ``mix'' two classages together to form a bigger classage, a compound classage. A compound classage is defined as follows:

classage X = Y + Z with P >> Q
or
classage X = Y + Z with P >> Q as R

In both cases, X is formed by ``hooking up'' the P mixer of classage Y and the Q mixer of classage Z. The difference is whether the result of ``hooking up'' P and Q leads to the creation of a new mixer for X. For the first case, the answer is no and we therefore call this form compound with consumed mixers. In contrast, the second form is called compound with re-exported mixers. Technically, ``hooking up'' a pair of mixers is a process of having imports of one side satisfied by exports of the other, detailed in the paper.

Obviously, It is possible to have multiple mixer pairs ``hooked up'' during one mixing process:

classage X = Y + Z with P >> Q, U >> V
or
classage X = Y + Z with P >> Q as R, U >> V as W

The compound classage can also define its own constructors. For instance,

classage X = Y + Z with P >> Q {
     X() { :Y(); :Z(); }
     X(int x) {this(); }
}
denotes X has two constructors, distinguishable by different argument types: When a compound classage does not define its own constructor (such as in the simple form introduced at the beginning of this section), a default constructor taking no argument is implicitly defined. However, if any explicit constructor is defined, the default constructor would not be added.

Well-formedness and Typechecking

A compound classage classage X = Y + Z with P » Q or classage X = Y + Z with P » Q as R fails to typecheck iff

For the compound classage with consumed mixers only, typechecking of classage X = Y + Z with P » Q fails iff

For the compound classage with re-exported mixers only, typechecking of classage X = Y + Z with P » Q as R fails iff

For compound classages with explicitly defined constructors, the compiler complains iff:

Here is an example to demonstrate how the compiler rejects all programs that fall into the aforementioned conditions.