§9.1 Defining classes with value parameters

(a) Value parameter declaration

Within the angle brackets that mark the parameters of a generic class also value parameters can be declared. In contrast to a type parameter, a value parameter is denoted as a pair of two identifiers: a type and a free name, e.g.,

class MyClass<YourType aName> { ...

Note that value parameters are valid for classes only, not for interfaces.

(b) Value parameter application

Within the given class (MyClass) the parameter name (aName) can be used like a final field of the given type (YourType). In contrast to regular final fields the assignment to this name occurs even before the constructor is executed.

(c) Role types as dependent types

Any role type can be interpreted as a value dependent type, however, in the declaration of a role type the value parameter remains implicit: it is identical to the enclosing team instance.