Writing Hygienic Macros in Scheme with Syntax-Case
This article describes a pattern-based hygienic macro system for Scheme and provides numerous examples of its use. Macros defined using this system are automatically hygienic and referentially transparent. Unlike earlier hygienic macro systems, this system does not require “low level” macros to be written in a different style from “high level” macros. In particular, automatic hygiene, referential transparency, and the ability to use patterns extend to all macro definitions, and there is never any need to explicitly manipulate syntactic environments of any kind. The macro system also supplies a hygiene-preserving mechanism for controlled variable capture, allowing macros to introduce implicit identifier bindings or references.