Skip to Main Content
Programming Clojure, 3rd Edition
book

Programming Clojure, 3rd Edition

by Alex Miller, Stuart Halloway, Aaron Bedra
February 2018
Intermediate to advanced content levelIntermediate to advanced
304 pages
7h 11m
English
Pragmatic Bookshelf
Content preview from Programming Clojure, 3rd Edition

Making Macros Simpler

The unless macro is a great simple example, but most macros are more complex. In this section, we’ll build a set of increasingly complex macros, introducing Clojure features as we go. For your reference, the following table summarizes the features introduced.

Form

Description

foo#

Auto-gensym: Inside a syntax-quoted section, create a unique name prefixed with foo.

(gensym prefix?)

Create a unique name, with optional prefix.

(macroexpand form)

Expand form with macroexpand-1 repeatedly until the returned form is no longer a macro.

(macroexpand-1 form)

Show how Clojure will expand form.

(list-frag? ~@form list-frag?)

Splicing unquote: Use inside a syntax quote to splice an unquoted list into a template.

‘form

Syntax quote: Quote form, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming Kotlin

Programming Kotlin

Venkat Subramaniam
Getting Clojure

Getting Clojure

Russ Olsen

Publisher Resources

ISBN: 9781680505719Errata Page