TemplatesTemplates are syntactically correct skeletons containing placeholders to be filled in by the user. Templates are especially convenient for inserting wordy or syntactically complex structures. Templates are a simple form of transform.
![]() |
Pull down the Transforms menu in the *untitled* window. | |
|
Whenever you are directed in the text to ``invoke'' a transform, you may do so in any of several different ways, depending on your taste:
| (X Windows) Clicking on a transform button in the context pane. |
We now illustrate the top-down insertion of templates.
|
Invoke the procedure-body transform, either by name or by selection from the Transforms menu. | |
|
The template replacing the <compilation_item> placeholder contains boilerplate code for a procedure-body, with placeholders for required constituents (e.g., <identifier> and <statement>) and optional constituents (e.g., <context_clause> and <basic_declarative_item>). The line of dashes (and one tilde) is a Software Productivity Consortium style guideline that is automatically enforced.
Template insertion always occurs at the location of the structural selection. After the template is inserted, the structural selection typically moves to the first placeholder within the template. For example, the new structural selection is <context_clause>. Whenever the structural selection is moved, the Transforms menu are updated accordingly.
| (X Windows) The context pane is updated also. |
Invoke the with-clause transform.
Placeholders can be replaced in arbitrary order.
|
Click on the <statement> placeholder. | |
|
Invoke the if transform.
Templates can be used to create programs in this top-down fashion all the way down to identifiers and constants. However, by the time one reaches the level of an expression, it is usually counterproductive to continue using templates, as straight textual entry is more convenient. Nonetheless, for illustration, we shall enter a few expression templates.
Invoke the and transform.
Invoke the or transform.
Note that parentheses are inserted automatically to indicate the association of operations.