Some 8 years ago for my master thesis I wrote a simple macro expander for Scheme, which implemented a pattern language akin to syntax-rules.
At that time, I didn't know about Matthew Flatt's "Let's Build a Hygienic Macroexpander" Strangeloop tutorial, the Clinger-Wand HOPL paper about hygienic macros wasn't yet written, and I didn't know anything about Kohlbecker's work .
So I built a much simpler device - something that operated on s-expressions rather than syntax-objects, and something that doesn't track the scope of identifiers, but instead implements the following rules:
- if a symbol was quoted, it was inserted verbatim into the substitution
- if a symbol appears in both a pattern and a template, the form matched by the pattern is rewritten to the output
- otherwise the expander inserts a gensym'd identifier
I honestly think that this simple set of rules is better than the hygienic expander from syntax-rules: it is both simpler (no scope tracking) and more powerful (makes it easier to break hygiene, and doesn't require the use of generate-temporaries), but if someone wants to prove me wrong, I recently dug it up from my master thesis, and after a number of fixes, it currently works under Guile, and is available here:
GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.
All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.