Learn how to extend Clojure using macros

Have you ever wanted a language that adapts to your software? Have you ever wanted to eliminate boilerplate? What about extend the syntax without changing the compiler? Those are what macros let you do.

If you've ever wanted to learn Clojure macros, this course is the place to start. This course jumps right into macros with gusto. It starts with the key to understanding macros, takes you through the implementation of 6 progressively more complex macros, and finishes with the three reasons you need macros.

Want this course?

Team License

$499
  • HD Download
  • Watch Online
  • Lifetime Access
  • For your company

Download License

$75
  • HD Download
  • Watch Online
  • Lifetime Access
  • For an individual

Online License

$48
  • Watch Online
  • Lifetime Access
  • For an individual

Membership

$49/mo
  • HD Downloads
  • Watch Online
  • Full access
  • All Content
  • For an individual
Get access

Love it or leave it guarantee

If you don't learn as much from this course as you thought, just ask for a refund within 30 days and I'll give you your money back.

Extra Resources

Register for a free account or log in to access these resources.

  • Clojure Macro Patterns Reference

    We tend to code using patterns that we repeat a lot. Learning these patterns can help you level up your macro skills very quickly. This reference sheet contains six annotated patterns that Clojure programmers use all the time.

  • Clojure Macro Sigils Reference

    Have you ever wondered what the symbols in Clojure macros do? I’m talking about `, ~, ~@, etc. This handy reference sheet tells you what they all do, when to use it, and shows examples. Never get lost in a macro again!

  • Clojure Macroexpand Reference

    When we’re developing macros, it really helps to be able to see what code it will output. Fortunately, Clojure comes with three built-in functions for doing just that. They are so useful for debugging. This reference sheet shows what each one does. It also includes how to access macroexpansion in the three most popular Clojure IDEs.

Beginning with Clojure Macros

Lessons

Video time: 01h38m

0 / 11

The key to understanding macros
  • 5 min
  • free

Do you know the key to really understanding macros? This lesson explains it. It's simpler than you think.

Writing our first macro
  • 11 min
  • free

We jump right in and start coding a simple macro, discovering the sigils we need along the way.

How to tackle difficult macros
  • 2 min

Before we dive into our more complex macros, we equip ourselves with a powerful technique that focuses our mental powers on the data transformation at the heart of macros.

Understanding macroexpansion
  • 6 min

We need one last tool before we begin our exploration. In order to debug our macros, we need to see what code they are outputting. There are three levels of macroexpansion to learn.

Macro example: when
  • 6 min

Clojure's built-in when is a macro that expands into if. Let's write a version ourselves.

Macro example: while
  • 6 min

Clojure's while loop is also a macro. Let's make one ourselves!

Macro example: regex
  • 12 min

Let's build an interesting macro to simulate regular expression features of Perl and Ruby: automatically binding locals to the match and groups.

Macro example: with-open
  • 19 min

One of the more interesting uses of macros is to make with- macros. These bind locals but also do something with them at the end. Let's build with-open.

Macro example: mf
  • 13 min

This is an experimental macro that I came up with. It makes a function that "wraps" a macro so that it can be used at runtime.

How to know when you need a macro
  • 4 min

People say you shouldn't write a macro unless you need one. I don't know if that's true (it's controversial in the Lisp world). But how do you know you need one?

A deeper explanation of with-open
  • 14 min

Do you understand the pattern of using helper functions within a macro and how it can make your macro more useful and easier to understand?