Next: Formal Description, Previous: Nestable pragmats in Algol 68, Up: Nestable pragmats in Algol 68
The Algol 68 strict language defines two styles for pragmats, each style using a different delimiter symbol:
bold pragmat symbol | pragmat |
style i pragmat symbol | pr |
In both cases the same symbol marks the beginning and end of the
pragmat: a bold pragmat starts with pragmat and it must be
ended by another pragmat; a style i pragmat starts
with pr and ends with a pr. These delimiters
are not ideal, for several reasons.
First, using the same symbol for starting and ending a pragmat makes it necessary to inspect the whole source in order to determine, given a delimiter, whether it begins or finishes the construct. For programmers this can be confusing and error prone, for programs such as text editors wanting to highlight a pragmat, or to skip over it, this can be very inefficient.
Pragmats using that kind of delimiters cannot be nested. This may not seem like a significant limitation at first. Other constructs, such as comments, are often nested, but not annotations for the compiler. However, the ability of doing so may be useful in order to combine several pragmats without having to resort to other language constructs.
The shortcomings described in the previous section motivate the addition of nestable pragmat delimiters to Algol 68.
Representations of pragmats are defined for the bold and i styles, both of which use symmetric delimiters:
bold pragmat begin symbol | order |
bold pragmat end symbol | redro |
style i pragmat begin symbol | [[ |
style i pragmat end symbol | ]] |
In Algol 68 the contents of several contiguous pragmats (ignoring possibly intermixed comments) are combined via simple concatenation into a string that is then interpreted as a single pragmat.
For example, the following pragmats:
[[un]] [[used]]
are equivalent to:
[[unused]]
When nested pragmats are found, they are expanded into the contents of the containing pragmat, including both delimiters and contents. This makes it possible for pragmats to operate on other pragmats. For example, the following pragmats may be a no-op:
[[unused]] [[ignore [[unused]]]]
Next: Formal Description, Previous: Nestable pragmats in Algol 68, Up: Nestable pragmats in Algol 68