Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing scheme style macros in clojure

Tags:

clojure

scheme

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.

like image 604
zcaudate Avatar asked Jul 09 '14 22:07

zcaudate


2 Answers

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.

like image 145
Greg Hendershott Avatar answered Oct 02 '22 22:10

Greg Hendershott


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.

like image 40
Arthur Ulfeldt Avatar answered Oct 02 '22 22:10

Arthur Ulfeldt