Next: TC-4 Samples, Up: TC-4 [Contents][Index]
Things to learn during this stage that you should remember:
Functions template are quite convenient to factor code that looks alike
but differs by the nature of its arguments. Member function templates
are used to factor error handling the TypeChecker
.
You will be asked why there can be no such thing in C++.
Although quite different in nature, types and functions are processed in a similar fashion in a Tiger compiler: first one needs to visit the headers (to introduce the names in the scope, and to check that names are only defined once), and then to visit the bodies (to bind the names to actual values). We use templates and template specialization to factor this. See also the Template Method.
The Template Method allows to factor a generic algorithm, the steps of which are specific. This is what we use to type check function and type declarations. Do not confuse Template Method with member function template, the order matters. Remember that in English the noun is usually last, preceded by qualifier.
What it is, how to implement it.
What it means, and when the C++ standard requires it from the compiler.