# \#book-metaprogramming-elixir

**URL:** https://forum.elixirforum.com/tag/book-metaprogramming-elixir/253.md

[Latest](https://forum.elixirforum.com/latest.md) · [Categories](https://forum.elixirforum.com/categories.md) · [Tags](https://forum.elixirforum.com/tags.md)

---

## [Clear definition of unquote fragments](https://forum.elixirforum.com/t/clear-definition-of-unquote-fragments/13063)

<div class="topic-metadata">

**Author:** [@amalbuquerque](https://forum.elixirforum.com/u/amalbuquerque)\
**Replies:** 5\
**Last updated:** [November 28, 2025, 1:35pm UTC](https://forum.elixirforum.com/t/clear-definition-of-unquote-fragments/13063 "2025-11-28T13:35:52Z")

</div>

Hi there, After reading @ericmj response here (Using unquote outside of quote block - #6 by ericmj) about “unquote fragments”, I still can’t completely grasp the concept. I’ve read the documentation many times now, bes…

---

## [How have you used Metaprogramming in Elixir?](https://forum.elixirforum.com/t/how-have-you-used-metaprogramming-in-elixir/65818)

<div class="topic-metadata">

**Author:** [@cobra](https://forum.elixirforum.com/u/cobra)\
**Replies:** 24\
**Last updated:** [December 21, 2024, 3:13pm UTC](https://forum.elixirforum.com/t/how-have-you-used-metaprogramming-in-elixir/65818 "2024-12-21T15:13:47Z")

</div>

Has anyone tried exploring Metaprogramming before. I think it’s a really powerful technique. I was looking for someone who has implemented it on any feature he or she was building. This would help me further know where I…

---

## [Can someone please explain this 'my\_if' code in the Metaprogramming Elixir book?](https://forum.elixirforum.com/t/can-someone-please-explain-this-my-if-code-in-the-metaprogramming-elixir-book/1617)

<div class="topic-metadata">

**Author:** [@voger](https://forum.elixirforum.com/u/voger)\
**Replies:** 11\
**Last updated:** [August 12, 2022, 2:38am UTC](https://forum.elixirforum.com/t/can-someone-please-explain-this-my-if-code-in-the-metaprogramming-elixir-book/1617 "2022-08-12T02:38:24Z")

</div>

I just finished “Programming Elixir” and now I am reading “Metaprogramming Elixir”. I can’t say I comprehend everything. I try to understand but I mostly pretend I understand and keep reading. While the previous example…

---

## [Metaprogramming Elixir (Pragprog)](https://forum.elixirforum.com/t/metaprogramming-elixir-pragprog/5886)

<div class="topic-metadata">

**Author:** [@AstonJ](https://forum.elixirforum.com/u/AstonJ)\
**Replies:** 13\
**Last updated:** [April 1, 2022, 11:04am UTC](https://forum.elixirforum.com/t/metaprogramming-elixir-pragprog/5886 "2022-04-01T11:04:58Z")

</div>

Don’t forget you can get 35% off the ebook using the code ‘devtalk.com’ :023:

---

## [What is the "do" in a defmacro param?](https://forum.elixirforum.com/t/what-is-the-do-in-a-defmacro-param/36450)

<div class="topic-metadata">

**Author:** [@mcgingras](https://forum.elixirforum.com/u/mcgingras)\
**Replies:** 3\
**Last updated:** [December 27, 2020, 3:14am UTC](https://forum.elixirforum.com/t/what-is-the-do-in-a-defmacro-param/36450 "2020-12-27T03:14:04Z")

</div>

Hello all, I’ve been reading about metaprogramming and encountered examples that look like the following: defmodule example(example\_param, do: block) I haven’t encountered syntax with the do param like that before, an…

---

## [Metaprogramming Elixir book: what does this mean?](https://forum.elixirforum.com/t/metaprogramming-elixir-book-what-does-this-mean/16169)

<div class="topic-metadata">

**Author:** [@7stud](https://forum.elixirforum.com/u/7stud)\
**Replies:** 4\
**Last updated:** [August 30, 2018, 1:04am UTC](https://forum.elixirforum.com/t/metaprogramming-elixir-book-what-does-this-mean/16169 "2018-08-30T01:04:27Z")

</div>

On p. 6, there is this example: defmodule Math do # {:+, \[context: Elixir, import: Kernel\], \[5, 2\]} defmacro say({:+, \_, \[lhs, rhs\]}) do #line 4 quote do lhs = unquote(lhs) rhs = unquote(rhs) …

---

## [Need help about quote and unquote](https://forum.elixirforum.com/t/need-help-about-quote-and-unquote/14679)

<div class="topic-metadata">

**Author:** [@dokuzbir](https://forum.elixirforum.com/u/dokuzbir)\
**Replies:** 8\
**Last updated:** [June 14, 2018, 12:43am UTC](https://forum.elixirforum.com/t/need-help-about-quote-and-unquote/14679 "2018-06-14T00:43:34Z")

</div>

This code is from metaprograming elixir book. I dont understand when should use unquote. In first function there is no unqote to execute expression but in second function there is unquote why ? defmodule ControlFlow do …

---

## [How to determine why elixir compilation w/ a macro is taking 202seconds](https://forum.elixirforum.com/t/how-to-determine-why-elixir-compilation-w-a-macro-is-taking-202seconds/6322)

<div class="topic-metadata">

**Author:** [@jeffdeville](https://forum.elixirforum.com/u/jeffdeville)\
**Replies:** 9\
**Last updated:** [June 27, 2017, 3:27pm UTC](https://forum.elixirforum.com/t/how-to-determine-why-elixir-compilation-w-a-macro-is-taking-202seconds/6322 "2017-06-27T15:27:31Z")

</div>

I’ve got a macro that wasn’t impacting my project compilation speed much. I added a small feature to it, and now it’s ~50x slower. But at least to look at it, it certainly doesn’t appear as if 50x more work is being don…

---

## [Can someone enlighten me on this piece of code?](https://forum.elixirforum.com/t/can-someone-enlighten-me-on-this-piece-of-code/6104)

<div class="topic-metadata">

**Author:** [@laiboonh](https://forum.elixirforum.com/u/laiboonh)\
**Replies:** 8\
**Last updated:** [June 21, 2017, 3:34am UTC](https://forum.elixirforum.com/t/can-someone-enlighten-me-on-this-piece-of-code/6104 "2017-06-21T03:34:51Z")

</div>

This is a code snippet from the metaprogramming elixir book. defmacro test(description, do: test\_block) do test\_func = String.to\_atom(description) quote do @tests {unquote(test\_func), unquote(description)}…

---

## [Trying to define my own if macro](https://forum.elixirforum.com/t/trying-to-define-my-own-if-macro/6058)

<div class="topic-metadata">

**Author:** [@laiboonh](https://forum.elixirforum.com/u/laiboonh)\
**Replies:** 6\
**Last updated:** [June 17, 2017, 3:39am UTC](https://forum.elixirforum.com/t/trying-to-define-my-own-if-macro/6058 "2017-06-17T03:39:41Z")

</div>

defmodule Control do defmacro my\_if(expr, do: if\_block, else: else\_block) do quote do Control.do\_my\_if(unquote(expr), do: unquote(if\_block), else: unquote(else\_block)) end end defmacro my\_if(expr, do…
