Expansion process

The description of macro expansion in R6RS is considerably more involved than in R5RS: One reason is that the specification of expansion in R5RS is ambiguous in several important respects. For example, R5RS does not specify whether define is a binding form. Also, it was not clear whether definitions of macros had to precede their uses. The fact that the set of available bindings may influence the matching process of macro expansion further complicates matters. The specific algorithm R6RS describes is one of the simplest expansion strategies that addresses these questions. It has the advantage that it visits every subform of the source code only once.

The description of the expansion process specifically avoids specifying the recursive case, where a macro use expands into a definition whose binding would influence the expansion of the macro use after the fact, as this might lead to confusing programs. Implementations should detect such cases as syntax violations.