What Are Elixir Macros, The Most Powerful Elixir Feature — Tentamen Software Testing Blog

Elixir Macro Run in IEx

TL;DR

Transformations On Compile Time

defmacro is Elixir’s keyword for Macro definition. Macro also belongs to Module. quote and unquote are core Elixir metaprogramming features. More about that could be read in Metaprogramming Elixir.

In the above screenshot, you can see how to use our If Macro. It is mandatory to Import it. Otherwise, you will get a very cryptic error. You can try what happens when you use :false as the first argument.

Originally published at https://blog.tentamen.eu on October 28, 2020.

--

--

Founder of Tentamen, software testing agency.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store