21.4.4 Looping
There is no support in M4 for doing traditional iterations
(ie. `for-do' loops), however macros may invoke themselves. Thus,
it is possible to iterate using recursion. The recursive definition can
use conditionals (21.4.3 Conditionals) to terminate the loop at its
completion by providing a trivial case. The GNU M4
manual provides some clever recursive definitions, including a
definition for a forloop macro that emulates a `for-do'
loop.
It is conceivable that you might wish to use these M4 constructs when
writing macros to generate large amounts of in-line shell code or
arbitrarily nested if; then; fi statements.
|