[Next] [Previous] [Up] [Top] [Contents] [Index]

10 Macros

Auxiliary Rule Sets

Auxiliary rule sets are like subroutines for rewrite rules. An auxiliary rule set rewrites the value of a pattern variable after it is bound by a pattern and before it is substituted into a template. Auxiliary rule sets only come into play after a pattern has matched; the failure of all patterns in an auxiliary rule set to match causes the entire macro call to be declared invalid, rather than back-tracking and trying the next pattern in the calling rule set.

See the definition of auxiliary-rule-sets in "Auxiliary Rule Sets" on page 414.

A symbol flags the beginning of an auxiliary rule set. For readability it is generally written as name: rather than #"name". The name of the symbol is the same as the name of the pattern variable that is rewritten by this auxiliary rule set. All occurrences of this pattern variable in all rule sets are rewritten. A pattern variable can occur in the very auxiliary rule set that rewrites that pattern variable; this is how you write recursive rewrite rules, which greatly expand the power of pattern-matching.

When an auxiliary rule set's pattern variable occurs in a double question-mark pattern-keyword, the auxiliary rule set rewrites each property value in the sequence individually.

The order of auxiliary rule sets in a macro definition is immaterial.

The ellipsis ... in patterns and templates of an auxiliary rule set means exactly the same thing as the pattern variable that is rewritten by this auxiliary rule set. Using ellipsis instead of the pattern variable can make recursive rewrite rules more readable.


Dylan Reference Manual - 17 OCT 1995
[Next] [Previous] [Up] [Top] [Contents] [Index]

Generated with Harlequin WebMaker