TC-3 Goals¶
Things to learn during this stage that you should remember:
- The Command design pattern
The Task module is based on the Command design pattern.
- Writing a Container Class Template
Class template are most useful to implement containers such as
misc::scoped_map.- Using methods from parents classes
super_typeand qualified method invocation to factor common code.- Template specialization
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.
- Traits
Traits are a useful technique that allows to write (compile time) functions ranging over types. The implementation of both hierarchies of visitors (const or not) relies on traits. You are expected to understand the code.
- Streams’ internal extensible arrays
C++ streams allows users to dynamically store information within themselves thanks to
std::ios::xalloc,std::stream::iword, andstd::stream::pword(see ios_base documentation by Cppreference). Indented output can use it directly inoperator<<, seelib/misc/indent.*andlib/misc/test-indent.cc. More generally, if you have to resort to usingprintbecause you need additional arguments than the sole stream, consider using this feature instead.Use this feature so that the
PrettyPrintercan be told from thestd::ostreamwhether escapes and bindings should be displayed.