|
|
Table of |
| §9. Value Dependent Classes |
![]() |
|
| Type Value Parameter | In addition to regular generics, a class may declare parameters that represent an object value. Such a value parameter is called the type anchor for this class, the class's type is said to be anchored to this parameter. |
![]() |
|
| Value Dependent Classes | A class that declares one or more value parameters depends on the runtime instance(s) denoted by its anchor(s). |
![]() |
|
| Externalized Roles | The concept of externalized roles (§ 1.2.2) is a special case of the concepts presented here. The syntax will eventually be migrated to use value parameters only. |
![]() |
|
MyClass<YourType p> is denoted as
MyClass<@v>.
In this term v must be a value which is conform to the declaration of the value parameter YourType p, ie., v must have the static type YourType.final.
Obviously, only the first element in such a path can be
a local variable or a method argument, all other elements
have to be fields. The reason for requiring final variables is
in type checking as discussed next.this as the anchor of any of its types, type checking an application of this method performs the following substitutions:this expression is substituted by the actual call target of the method application.Outer.this expression is substituted by the corresponding enclosing instance of the call target.
final identifier to another final identifier are transitively followed, i.e., if t1, t2 are final, after an assignment t1=t2 the types C<@t1> and C<@t2> are considered identical. Otherwise C<@t1> and C<@t2> are incommensurable.|
|
Table of |