4 ms·
Thanks for this. It's a great overview that manages to be both detailed and easily accessible. Your visual approach to explaining macros with arrows to demonst
by danenania 13y ago
Thanks for this. It's a great overview that manages to be both detailed and easily accessible.
Your visual approach to explaining macros with arrows to demonstrate the substitutions also really helped me to grok them in a way I haven't been able to previously. They are actually quite simple aren't they? It's basically the same idea as html templating, but outputs code instead of markup.
I'd love to see you get more in depth on some of the headier topics--core.logic, monads, storm/hadoop interop, etc. You seem to have a gift for making difficult concepts approachable.
- billsix 13y agoyou may enjoy On Lisp. http://www.paulgraham.com/onlisp.html http://www.paulgraham.com/onlisp.html
- coolsunglasses 13y agoStructure-aware, fully programmable (you use your full programming language at macro-expansion time) HTML templates, sure.
- JackMorgan 13y agoI wrote a post about macros in Clojure going into some more detail if you're interested in learning a bit more. http://deliberate-software.com/intro-to-macros/ http://deliberate-software.com/intro-to-macros/
- brandonbloom 13y agoTo be clear, that ` character is called "syntax-quote" (in Clojure; "quasi-quote" elsewhere) and it's the "templating" part. It's both possible and common to use macros without syntax-quote and vice versa. In fact, common practice in Clojure is to define a your macros in terms of a backing function: (defn foo-fn [body] (fancy stuff here that probably uses syntax-quote somewhere)) (defmacro foo [& body] (foo-fn body)) Clojure's style of macro system is known as a "procedural" macro system because the macros can be any arbitrary procedures which returns code as data. There are other types of macro systems, like Scheme's syntax-rules, which are more directly embrace the fact that most macros are tree rewrites.
- chc 13y agoSyntax-quote is a little bit different from quasiquote. Clojure's macros look a lot like Common Lisp's unhygienic macros, but Clojure's syntax-quote offers a sort of "hygiene by default" by forcing namespaces on variables and making it hard to introduce non-gensym symbols accidentally.
- brandonbloom 13y agoHence this project: https://github.com/brandonbloom/backtick https://github.com/brandonbloom/backtick