Simple Yet Compelling Macro Examples which are Not Already in Clojure

Viewed 1929

I'm trying to write a macro tutorial, and now I need some examples which are simple to understand, and yet compelling.

The problem is that a lot of the obvious things are already in clojure and contrib. And I feel that "look, we can reimplement all the library functions" might not be the best argument for why macros are so great.

Has anyone got any cute (one-liners are best) examples that they wouldn't mind me using?

Here are the first three parts of the tutorial. It's a bit ropy at the moment, so any comments about how it could be made better would be gratefully received.

http://learnclojure.blogspot.com/2010/09/clojure-macro-tutorial-part-i-getting.html

http://learnclojure.blogspot.com/2010/09/clojure-macro-tutorial-part-ii-compiler.html

http://learnclojure.blogspot.com/2010/09/clojure-macro-tutorial-part-ii-syntax.html

2 Answers
Related