Post AtdymR7EOwXqGNrumu by PaniczGodek@functional.cafe
 (DIR) More posts by PaniczGodek@functional.cafe
 (DIR) Post #AtdymR7EOwXqGNrumu by PaniczGodek@functional.cafe
       2025-04-26T07:08:07Z
       
       0 likes, 1 repeats
       
       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 identifierI 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:https://github.com/panicz/jsssssssss/blob/main/expander.scm