[Next] [Previous] [Up] [Top] [Contents] [Index]
4.1 Parameterized Declarations
forall Clause: the Backquote Sugar Type variables can be introduced implicitly -- without listing them in the forall clause. This provides a more concise notation for parameterized declarations by omitting the explicit forall prefix. A type variable is introduced implicitly in a declaration if:
') somewhere in its header (see more on the backquote sugar in Section 4.2), or
So the declarations from the previous example can be rewritten more concisely as:
template object i_vector[T];
extend i_vector['T] isa collection[T];
method fetch(a@:i_vector['T], index:int):T  { ... }
 The expressions remain the same since the backquote sugar does not affect whether or not a type parameter is explicit. Note that the names of type variables shadow names of globally visible types, whether the variables are introduced in a forall clause, using the backquote sugar, or as an explicit type parameter. For example, if a declaration introduces a type variable called int, all occurrences of int in that declaration will refer to that type variable and not the predefined integer type.
[Next] [Previous] [Up] [Top] [Contents] [Index]
Generated with Harlequin WebMaker