defmacro
defmacro
defmacro

Last updated on 2014-01-17

About the Book

This book explores everything you need to know about Macros and how to write them.

Examples are mainly written in Elixir (http://elixir-lang.org/) but there is also smatterings of Clojure and other languages that do interesting things with Macros.

The Macro concepts explored are useful to to all implementations of Macros.

About the Author

Joseph Wilk
Joseph Wilk

Joseph Wilk works as an Engineer at SoundCloud helping infuse Clojure and Elixir into the organisation.

Blog: http://blog.josephwilk.net

Twitter: @josephwilk

Table of Contents

  • The Sharp knife
  • What are Macros?
  • Why Macros?
    • Compile time lazy evaluation
    • Macros vs Metaprogramming
  • Macro Basics
    • Quote
    • Unquote
    • Building Functions
    • Unquote Splicing
    • Macro Escaping
    • Eval quoted
    • Hygiene & Macros
    • Unhygienic
    • Unquoting outside of macros
  • Common mistakes
    • Calling macros with runtime arguments
    • Breaking syntax
    • Manually parsing quoted code
    • Unquoting multiple times
  • Macro Development Style
    • Minimize Footprint
    • Looking inside the Macro
    • Lead by an Example
    • Comparing Abstract Syntax Trees
    • Meaningful stacktraces
  • Types of Macros
    • Anonymous Macros
    • Anaphoric Macros
    • Reader Macros
  • References
  • Appendix 1: Elixir’s AST

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Write and Publish on Leanpub

Authors, publishers and universities use Leanpub to publish amazing in-progress and completed books and courses, just like this one. You can use Leanpub to write, publish and sell your book or course as well! Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks. Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. It really is that easy.

Learn more about writing on Leanpub