Deep Dive into Hygienic Macros in Scheme
Scheme's macro system employs a 'hygiene' mechanism to prevent variable name clashes during macro expansion. This article delves into the concept of identifiers in Scheme, which encompass not only a symbolic name but also a lexical context and a historical context. The predicates `bound-identifier=?` and `free-identifier=?` compare identifier equivalence; the former focuses on the interchangeability of bound identifiers after macro expansion, while the latter focuses on free identifiers. The article uses multiple examples to illustrate the differences between these two equivalence relations and the role of historical context in the hygienic macro mechanism. Ultimately, it explains how Scheme uses the historical information of identifiers to ensure macro hygiene and prevent variable name conflicts.