Book Image

Clojure Programming Cookbook

Book Image

Clojure Programming Cookbook

Overview of this book

When it comes to learning and using a new language you need an effective guide to be by your side when things get rough. For Clojure developers, these recipes have everything you need to take on everything this language offers. This book is divided into three high impact sections. The first section gives you an introduction to live programming and best practices. We show you how to interact with your connections by manipulating, transforming, and merging collections. You’ll learn how to work with macros, protocols, multi-methods, and transducers. We’ll also teach you how to work with languages such as Java, and Scala. The next section deals with intermediate-level content and enhances your Clojure skills, here we’ll teach you concurrency programming with Clojure for high performance. We will provide you with advanced best practices, tips on Clojure programming, and show you how to work with Clojure while developing applications. In the final section you will learn how to test, deploy and analyze websocket behavior when your app is deployed in the cloud. Finally, we will take you through DevOps. Developing with Clojure has never been easier with these recipes by your side!
Table of Contents (16 chapters)
Clojure Programming Cookbook
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface

Defining more advanced macros


When we started thinking about the structure of the book, it all kind of made sense to talk about simple macros and advanced macros. Now, arriving at the topic, the author has to admit it is not so clear anymore. So, what do we mean when we talk about advanced macros? We tried to ask Canon, but they would not give us a proper answer.

In this recipe, we will therefore state that an advance macro is a macro that generates a form that changes the flow of the evaluation of the resulting code. In the previous recipe on simple macros, the macros were, well, simple, because the form generated was always the same. This recipe will expose macros that always generate the same code or where the control flow gets slightly more complicated. The goal of course is to easily be able to write convenient macro in your code.

Getting ready

While there is no specific preparation for this recipe, let's have a look at the clojure.core when we have a macro to guide us:

(defmacro when ...