...

/

Using the Representation as Code

Using the Representation as Code

Understand how to inject our code into a program's internal representation.

Introduction

When we extract the internal representation of some code (either via a macro parameter or using quote), we stop Elixir from adding it automatically to the tuples of code it’s building during compilation. We’ve effectively created a free-standing island of code. How do we inject that code back into our program’s internal representation?

There are two ways.

The first is the macro. Just like with a function, the value a macro returns is the last expression evaluated in that macro. That expression is ...