next up previous contents index
Next: Pattern Matching Up: Algebraic Datatypes Previous: Algebraic Datatypes

Instantiating a datatype

Each declared datatype should be instantiated in some implementation file using the instantiate datatype  statement. The translator will generate additional code to implement the datatype. The general syntax is:


Instantiate_Decl ::=instantiate datatype Type_Spec, ¼ , Type_Spec
  |  instantiate extern datatype Type_Spec, ¼ , Type_Spec
Type_Spec ::=Id [ < TypeExp, ¼ , TypeExp > ]

Tips: a datatype is defined with the inline  qualifier, Prop will try to generate inline methods whenever possible. On the other hand, if the extern  qualifier is used, Prop will try to generate an non-inline implementation, and only one copy are generated at where the instantiate datatype statement occurs.

Since most Prop datatypes are light-weight objects, inline is taken as the default. The user can override this default using -save_space  option of the translator (see page gif).

Tips: the option -fno-implicit-templates  is used under G++, the user should #define the symbol   before an instantiate datatype statement. This will enable the code for explicit template instantiation.



Allen Leung
Mon Apr 7 14:33:55 EDT 1997