TutorialTemplates




Prev | Up | Next | Back | Forward | Tutorial Top

Templates 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.

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:

We now illustrate the top-down insertion of templates.

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.

Placeholders can be replaced in arbitrary order.

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.

Note that parentheses are inserted automatically to indicate the association of operations.


Forward