[Next] [Previous] [Up] [Top] [Contents] [Index]

4 Parameterization and Parametric Polymorphism

4.6 Parameterization and Syntactic Sugars

When desugaring a parameterized object declaration, the implied representation and type declarations are parameterized with the same formal type parameters. Similarly, when a method declaration is desugared, the implied implementation and signature declarations have the same explicit type parameters and formal argument types, including any implicit type parameter bindings. For example, the declarations

abstract object collection[T];
	method print(c@:collection['T <= printable]):void {...}
	method expand_tabs(c@:'T <= collection[char]):T {...}

abstract object table[Key,Value] isa collection[Value];
abstract object indexed[T] isa table[int,T];
template object array[T] isa indexed[T];
	method new_array[T](size:int, initial_value:T):array[T] {...}
are syntactic sugar for the following declarations:

type collection[T];
abstract representation collection[T] subtypes collection[T];
	signature print(collection['T <= printable]):void;
	implementation print(c@:collection['T <= printable]):void {...}
	signature expand_tabs('T <= collection[char]):T;
	implementation expand_tabs(c@:'T <= collection[char]):T {...}

type table[Key,Value] subtypes collection[Value];
abstract representation table[Key,Value] inherits collection[Value]
                                         subtypes table[Key,Value];
type indexed[T] subtypes table[int,T];
abstract representation indexed[T] inherits table[int,T]
                                   subtypes indexed[T];
type array[T] subtypes indexed[T];
template representation array[T] inherits indexed[T]
                                 subtypes array[T];
	signature new_array[T](int, T):array[T];
	implementation new_array[T](size:int, initial_value:T):array[T] {...}

The Cecil Language: Specification and Rationale, Version 2.1 - 25 MARCH 1997
[Next] [Previous] [Up] [Top] [Contents] [Index]

Generated with Harlequin WebMaker