Online Manual: Interface-Renamed Classages
Classages allows programmers to rename classage interfaces (mixers, pluggers or connectors) via the following top-level language construct:
classage X = Y rename P >> Qwhich means the newly defined classage X is the same as classage Y, except the interface named P in classage Y is now named Q in X.
The renamed classage can also define its own constructors, in much the same way as in compound classages. For instance,
classage X = Y rename P >> Q
X() {:Y(); }
X(int x) { this(); }
}
When a renamed classage does not define its own constructor, a default constructor taking no argument is implicitly defined. However, if any explicit constructor is defined, the default constructor would not be added.
Here is an example demonstrating different cases of renaming classage interfaces.
Well-formedness and Typechecking
An interface-renamed classage classage X = Y rename P » Q fails to typecheck iff:
- Y does not exist as an already defined classage.
- P is not an interface defined in Y.
- Q is already an interface defined in Y and P is not the same as Q; if so, such a renaming would end up equipping X with two different interfaces of the same name Q.
- Cyclic definitions exist, such as:
classage A = B rename P >> Q classage B = C rename Q >> R classage C = A rename R >> S
For interface-renamed classages with explicitly defined constructors, the compiler complains exactly the same way as for the compound classage to rule out ill-defined constructors, which we do not repeat here.
Here is an example to demonstrate how the compiler rejects all programs that fall into the aforementioned conditions.