I often read debates about why hygenic macros are better and that clojure's macro system is based upon Common Lisp and is not hygenic.
My question is: can a scheme style macro system be implemented in clojure and what are some examples of scheme style macros implanted in other lisps.
By "Scheme-style macro system", I'm not sure if you mean syntax-rules
(the simple pattern style system) or syntax-case
(the more flexible system which, along with datum->syntax
, actually does let you bend or flat-out break hygiene).
Also, Racket has syntax-parse
, which a bit simpler to use than syntax-case
and (among other things) makes it pleasant to write macros which give intelligible error messages.
Regardless of which you mean, there is a Clojure project that purports to implement aspects of all three. However I haven't tried it and I can't vouch for how successfully it does so.
I'm not sure it's accurate to say that Clojure's macro system is not hygienic. One similar discussion I have seen refers to common lisp's system for reader macros (which Clojure does not have) as being not hygienic because they lack a mechanism to keep reader macros in different modules from replacing each other. It was an explicit and intentional design decision to build the language such that Scheme-style macros where not included.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With