1 Polymorphic datatypes should be defined and used in the following manner:
3 (1) A polymorphic datatype is defined using the usual 'datatype'
4 declaration. This should be placed in a .ph file.
7 datatype TREE<T> = empty | leaf (T) | node (TREE<T>, T, TREE<T>);
9 (2) Any additional refinement can be declared in the same file
10 (or some other .ph file that includes the .ph file with
11 the datatype declaration)
12 using the 'refine' declaration.
15 // Now the tree is also has pretty printers
16 // and is garbage collected.
17 refine TREE<T> :: printable collectable;
19 (3) We must give Prop an indication of the parameters with which we
20 intend to instantiate the polymorphic datatype. This is done
21 with the 'instantiate extern datatype' declaration in an .ph file.
24 instantiate extern datatype TREE<int>, TREE<const char *>;
26 (4) Finally, we must instantiate the datatype with the
27 'instantiate datatype' declaration in a .pcc file. This will
28 generate all the appropriate methods and data for each instance.
31 instantiate datatype TREE<int>, TREE<const char *>;
33 This should be done only once in a single file and if done correctly,
34 should make it possible for you to generate only one copy of code
37 You can find some more examples in the tools/incoming directory.
38 I apologize for not having the documentation ready. You can also email
39 me for more clarification when needed.