<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Jorge Zaccaro</title>
    <description>The latest articles on Forem by Jorge Zaccaro (@boolpath).</description>
    <link>https://forem.com/boolpath</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F470333%2Fcf7185e7-163e-49d1-bc87-b204bd90b060.png</url>
      <title>Forem: Jorge Zaccaro</title>
      <link>https://forem.com/boolpath</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/boolpath"/>
    <language>en</language>
    <item>
      <title>Let Over Hiccup: Creating Closures with Reagent</title>
      <dc:creator>Jorge Zaccaro</dc:creator>
      <pubDate>Mon, 23 Nov 2020 18:00:07 +0000</pubDate>
      <link>https://forem.com/boolpath/let-over-hiccup-creating-closures-with-reagent-h0n</link>
      <guid>https://forem.com/boolpath/let-over-hiccup-creating-closures-with-reagent-h0n</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Sometimes it's called a &lt;em&gt;closure&lt;/em&gt;, other times a saved lexical environment. Or, as some of us like to say, &lt;em&gt;let over lambda&lt;/em&gt;.&lt;br&gt;
— &lt;a href="https://letoverlambda.com/"&gt;Let Over Lambda&lt;/a&gt;, &lt;a href="https://letoverlambda.com/index.cl/guest/chap2.html#sec_5"&gt;Chapter 2: Closures&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  λ
&lt;/h2&gt;

&lt;p&gt;When I started to learn &lt;a href="https://github.com/reagent-project/reagent"&gt;Reagent&lt;/a&gt;, I noticed a familiar pattern in &lt;a href="https://purelyfunctional.tv/guide/reagent/"&gt;form-2&lt;/a&gt; components that use a let binding to return a lexical closure, an idiom that &lt;a href="https://github.com/hoytech"&gt;Doug Hoyte&lt;/a&gt; elegantly calls &lt;strong&gt;let over lambda&lt;/strong&gt; in his book of the same title:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;"Let over lambda is a nickname given to a lexical closure. [...] In a let over lambda scenario, the last form returned by a &lt;em&gt;let&lt;/em&gt; statement is a &lt;em&gt;lambda&lt;/em&gt; expression. It literally looks like &lt;em&gt;let&lt;/em&gt; is sitting on top of &lt;em&gt;lambda&lt;/em&gt;."&lt;/p&gt;
&lt;/blockquote&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;"Sometimes the most valuable thing to have a let form return is an anonymous function which takes advantage of the lexical environment supplied by the &lt;em&gt;let&lt;/em&gt; form. To create these functions in lisp we use &lt;em&gt;lambda&lt;/em&gt;."&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;As Hoyte explains, "one way of thinking about closures is that they are &lt;strong&gt;functions with state&lt;/strong&gt;". In Common Lisp, this pattern can be used to create a counter by surrounding a &lt;code&gt;lambda&lt;/code&gt; expression with a &lt;code&gt;let&lt;/code&gt; form:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This expression returns a function that increments the &lt;code&gt;counter&lt;/code&gt; variable every time it is called. In Clojure, anonymous functions can be created using the &lt;code&gt;fn&lt;/code&gt; special form that is analogous to Common Lisp's &lt;code&gt;lambda&lt;/code&gt;: &lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;In Reagent, the simplest form of a let over lambda would create a similar let binding, but using &lt;code&gt;reagent.core/atom&lt;/code&gt; instead of &lt;code&gt;clojure.core/atom&lt;/code&gt; so that Reagent can watch for and re-render the component on state changes:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;However, here the inner function would be called only when rendering the component for the first time, but nothing would be able to access or increment the value of &lt;code&gt;counter&lt;/code&gt; and thus trigger the component to re-render.&lt;/p&gt;

&lt;p&gt;Let's modify the last snippet to return a &lt;a href="https://github.com/weavejester/hiccup"&gt;Hiccup&lt;/a&gt; vector that describes an HTML button, adds an event listener that increments the &lt;code&gt;counter&lt;/code&gt; on every click, and contains a child expression that dereferences the &lt;code&gt;counter&lt;/code&gt;:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This closure will remember the number of times that the button has been clicked. After being initialized with a value of &lt;code&gt;0&lt;/code&gt;, the value of &lt;code&gt;counter&lt;/code&gt; will be incremented by &lt;code&gt;1&lt;/code&gt; every time the &lt;code&gt;#(swap! counter inc)&lt;/code&gt; function is called.&lt;/p&gt;

&lt;p&gt;Finally, let's turn this button into an actual component with state by using the above way of creating closures with Reagent. But in order to create such closures &lt;em&gt;as needed&lt;/em&gt;, we must define a function that returns a let over lambda: &lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Coincidentally, this pattern used to create Reagent components with state is exactly what Hoyte calls "lambda over let over lambda". That is, &lt;strong&gt;form-2 components follow the lambda over let over lambda pattern:&lt;/strong&gt;&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Thus, every time &lt;code&gt;create-counter-button&lt;/code&gt; is called, a new closure will be created to store the state of the new button in it's own lexical environment. It's amazing that this can be accomplished without objects and classes at all!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Let and lambda are fundamental; objects and classes are derivatives. As Steele says, the "object" need not be a primitive notion in programming languages. — &lt;a href="https://letoverlambda.com/"&gt;Let Over Lambda&lt;/a&gt;, &lt;a href="https://letoverlambda.com/index.cl/guest/chap2.html#sec_5"&gt;Chapter 2&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Much like "let over lambda is a nickname given to a lexical closure", we can say that &lt;strong&gt;Let Over Hiccup&lt;/strong&gt; is a nickname for a closure that returns a Hiccup vector, regardless of how many layers of let over lambdas and nested components there will be in more sophisticated compositions.&lt;/p&gt;

&lt;p&gt;I think it's very interesting and surprising that a simple example of a Reagent component uses a pattern that gives its name to an advanced book on Lisp macros. I'm really  excited to figure out what other topics about macros can be applied to the seemingly unrelated field of functional components for building user interfaces on the Web.&lt;/p&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.lulu.com/en/en/shop/doug-hoyte/let-over-lambda/paperback/product-18dzger.html"&gt;Let Over Lambda&lt;/a&gt;: 50 Years of Lisp, by &lt;a href="https://hoytech.com/"&gt;Doug Hoyte&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://reagent-project.github.io/"&gt;Reagent&lt;/a&gt;: A simple &lt;a href="https://clojurescript.org/"&gt;ClojureScript&lt;/a&gt; interface to &lt;a href="https://reactjs.org/"&gt;React&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>clojure</category>
      <category>react</category>
      <category>webdev</category>
      <category>lisp</category>
    </item>
    <item>
      <title>A "Hello, World!" of Lisp Macros</title>
      <dc:creator>Jorge Zaccaro</dc:creator>
      <pubDate>Fri, 30 Oct 2020 15:07:04 +0000</pubDate>
      <link>https://forem.com/boolpath/a-hello-world-of-lisp-macros-4o5f</link>
      <guid>https://forem.com/boolpath/a-hello-world-of-lisp-macros-4o5f</guid>
      <description>&lt;h1&gt;
  
  
  "Hello, macros!"
&lt;/h1&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Common Lisp:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
&lt;strong&gt;Clojure:&lt;/strong&gt;&lt;br&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  Context
&lt;/h2&gt;

&lt;p&gt;As a Lisp beginner, I think the most succinct program capable of portraying the beauty of Lisp is &lt;code&gt;(+)&lt;/code&gt;. I first saw this expression in Paul Graham's ANSI Common Lisp (page 8) [1], and despite its apparent simplicity I found it shockingly powerful. In this post, I use the &lt;code&gt;(+)&lt;/code&gt; expression to explore the notion of "code as data" in Common Lisp, and try to figure out what the "Hello, World!" of Lisp macros is, a challenge proposed by the book's author in &lt;a href="https://twitter.com/paulg/status/1260138502974570497" rel="noopener noreferrer"&gt;this tweet&lt;/a&gt;.&lt;br&gt;
&lt;iframe class="tweet-embed" id="tweet-1260138502974570497-498" src="https://platform.twitter.com/embed/Tweet.html?id=1260138502974570497"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1260138502974570497-498');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1260138502974570497&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;h2&gt;
  
  
  Content
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The (quote ...) operator
&lt;/h3&gt;

&lt;p&gt;The key to understanding Lisp macros lies in the concept of &lt;strong&gt;protecting expressions from evaluation&lt;/strong&gt;. Lisp programs are expressed as lists, and programs are executed by evaluating their list representations. Protecting lists from evaluation means doing something to avoid their interpretation as programs (i.e. an operator followed by its arguments), or simply to &lt;em&gt;prevent their execution&lt;/em&gt; when they actually are programs. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;quote&lt;/code&gt; operator (abbreviated as &lt;code&gt;'&lt;/code&gt;) protects its arguments from evaluation. Clearly this is useful for building lists of data without triggering the &lt;em&gt;evaluation rule&lt;/em&gt; of function calls, but why would we want to prevent actual programs from being evaluated as such? In Lisp, the answer is straightforward: so that we can &lt;strong&gt;manipulate programs as data&lt;/strong&gt; and transform them into other programs. This is where macros come into play. But first, let's go back to &lt;code&gt;(+)&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  The (+) program
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;(+ 1 2 3)&lt;/code&gt; expression is a list representation of a Lisp program that adds the numbers 1 to 3 together. It uses &lt;em&gt;prefix notation&lt;/em&gt; to express that the arguments &lt;code&gt;1&lt;/code&gt;, &lt;code&gt;2&lt;/code&gt; and &lt;code&gt;3&lt;/code&gt; should be passed to the &lt;code&gt;+&lt;/code&gt; function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="nb"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="mi"&gt;6&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This notation makes the &lt;code&gt;+&lt;/code&gt; operator appear only once, whereas &lt;em&gt;infix notation&lt;/em&gt; would make it appear twice (1 + 2 + 3). The elegance of this approach is that it holds for an arbitrary number of arguments (e.g. &lt;code&gt;(+ 1 2 3 4 5 ...)&lt;/code&gt;), but what I find most surprising is that it holds for &lt;em&gt;zero arguments&lt;/em&gt; as well. We can thus write a program that adds &lt;em&gt;zero numbers&lt;/em&gt; together:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="nb"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="mi"&gt;0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is so beautiful, and even more so that it also holds for &lt;code&gt;(*)&lt;/code&gt;, &lt;code&gt;(and)&lt;/code&gt; and &lt;code&gt;(or)&lt;/code&gt;. Admittedly, a program that adds zero numbers together is not useful at all, unless we can somehow &lt;em&gt;modify it&lt;/em&gt; to take more arguments &lt;strong&gt;before it is evaluated&lt;/strong&gt;. One way of doing this modification is by &lt;em&gt;appending&lt;/em&gt; expressions to the list representation of the program. Let's try to use the built-in &lt;code&gt;append&lt;/code&gt; function to concatenate the &lt;code&gt;(+)&lt;/code&gt; program with the list &lt;code&gt;(1 2 3)&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="nb"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;append&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;list&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
           &lt;span class="err"&gt;|&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;append&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;list&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt;&lt;span class="nv"&gt;TYPE-ERROR...&lt;/span&gt;
&lt;span class="nv"&gt;The&lt;/span&gt; &lt;span class="nv"&gt;value&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nb"&gt;not&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="nv"&gt;LIST&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unfortunately, trying to evaluate this expression causes an error, because &lt;strong&gt;arguments passed to function calls are always evaluated&lt;/strong&gt;. Thus the &lt;code&gt;(+)&lt;/code&gt; program will evaluate to &lt;code&gt;0&lt;/code&gt; before we try to append  &lt;code&gt;(1 2 3)&lt;/code&gt;, and the &lt;code&gt;append&lt;/code&gt; function only takes lists as arguments. What we really need  is a way to concatenate arguments to the &lt;code&gt;(+)&lt;/code&gt; list.&lt;/p&gt;

&lt;h3&gt;
  
  
  The '(+) list
&lt;/h3&gt;

&lt;p&gt;Let's try to protect the &lt;code&gt;(+)&lt;/code&gt; program from evaluation before passing it to the &lt;code&gt;append&lt;/code&gt; function. We can do so with the &lt;code&gt;quote&lt;/code&gt; operator (here in abbreviated form):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="nb"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;'&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result of preventing the evaluation of the &lt;code&gt;(+)&lt;/code&gt; program is the &lt;code&gt;(+)&lt;/code&gt; list. Even though &lt;em&gt;they look exactly the same&lt;/em&gt;, the former is &lt;strong&gt;code&lt;/strong&gt;, while the latter is &lt;strong&gt;data&lt;/strong&gt;. This is the distinctive notion of "code as data" in Lisp. We can now use the &lt;code&gt;append&lt;/code&gt; function to concatenate the lists &lt;code&gt;(+)&lt;/code&gt; and &lt;code&gt;(1 2 3)&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="nb"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;append&lt;/span&gt; &lt;span class="o"&gt;'&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;'&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that both arguments are written with the &lt;code&gt;'&lt;/code&gt; operator, so as to prevent the evaluation of the &lt;code&gt;(+)&lt;/code&gt; expression as a program (which would return &lt;code&gt;0&lt;/code&gt;), as well as the evaluation of the &lt;code&gt;(1 2 3)&lt;/code&gt; expression as a function call (which would cause an error because &lt;code&gt;1&lt;/code&gt; is not a function). However, the resulting expression &lt;code&gt;(+ 1 2 3)&lt;/code&gt; &lt;strong&gt;is data, not code&lt;/strong&gt;, so we still need to find a way to make Common Lisp treat it as code. Would defining a function solve this problem?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;defun&lt;/span&gt; &lt;span class="nv"&gt;pass-args&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;code&lt;/span&gt; &lt;span class="k"&gt;&amp;amp;rest&lt;/span&gt; &lt;span class="nv"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;append&lt;/span&gt; &lt;span class="nv"&gt;code&lt;/span&gt; &lt;span class="nv"&gt;args&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="nb"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;pass-args&lt;/span&gt; &lt;span class="o"&gt;'&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unfortunately not. This &lt;code&gt;pass-args&lt;/code&gt; function evaluates the expression &lt;code&gt;(append code args)&lt;/code&gt;, where the &lt;code&gt;code&lt;/code&gt; parameter must be a list representation of a program, and &lt;code&gt;&amp;amp;rest args&lt;/code&gt; will build a list of zero or more arguments to be passed to &lt;code&gt;code&lt;/code&gt;. But whether we call the &lt;code&gt;append&lt;/code&gt; function directly or define a function that calls &lt;code&gt;append&lt;/code&gt; internally, the final expression still needs to be evaluated as code. What else could we try then? Enter &lt;code&gt;(eval ...)&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="nb"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;append&lt;/span&gt; &lt;span class="o"&gt;'&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;'&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
&lt;span class="mi"&gt;6&lt;/span&gt;
&lt;span class="nb"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;pass-args&lt;/span&gt; &lt;span class="o"&gt;'&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="mi"&gt;6&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These expressions finally produce the desired result. However, calling &lt;code&gt;eval&lt;/code&gt; is not the best way to &lt;em&gt;cross the line between data and code&lt;/em&gt; [1] (page 161) mainly due to efficiency reasons (run-time vs compile-time). As we shall see next, macros are in fact the best way to manipulate code as data and evaluate data as code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hello, (defmacro ...)!
&lt;/h3&gt;

&lt;p&gt;Macros are programs that write programs [2]. They do so by handling programs as data and evaluating their transformed representations as code. This is possible because, unlike functions, &lt;strong&gt;macros do not evaluate their arguments&lt;/strong&gt; when they are passed. Thus, in order to modify the &lt;code&gt;(+)&lt;/code&gt; program, we can redefine the &lt;code&gt;pass-args&lt;/code&gt; function as a macro and call it with an &lt;em&gt;unquoted&lt;/em&gt; expression of the &lt;code&gt;(+)&lt;/code&gt; program:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;defmacro&lt;/span&gt; &lt;span class="nv"&gt;pass-args&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;code&lt;/span&gt; &lt;span class="k"&gt;&amp;amp;rest&lt;/span&gt; &lt;span class="nv"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;append&lt;/span&gt; &lt;span class="nv"&gt;code&lt;/span&gt; &lt;span class="nv"&gt;args&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="nb"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;pass-args&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="mi"&gt;6&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We finally get &lt;code&gt;6&lt;/code&gt; instead of just &lt;code&gt;(+ 1 2 3)&lt;/code&gt;. Notice that, in contrast to the &lt;code&gt;pass-args&lt;/code&gt; function call, there is no need to use the quote &lt;code&gt;'&lt;/code&gt; operator before the &lt;code&gt;(+)&lt;/code&gt; program because &lt;strong&gt;macros operate on the unevaluated expressions for the arguments&lt;/strong&gt; [3]. But once inside the body of a macro, we do need a way to specify that we want to treat some data as code again before returning the value of the transformed expression.&lt;/p&gt;

&lt;p&gt;The backquote &lt;code&gt;`&lt;/code&gt; operator &lt;strong&gt;turns evaluation off&lt;/strong&gt; like the regular quote &lt;code&gt;'&lt;/code&gt; operator, but we can use &lt;code&gt;,&lt;/code&gt; and &lt;code&gt;,@&lt;/code&gt; within a backquoted expression to &lt;strong&gt;turn evaluation back on&lt;/strong&gt; [1] (page 163). The &lt;code&gt;,@&lt;/code&gt; is especially useful because it inserts the elements of a list into a template, so given a term &lt;code&gt;,@args&lt;/code&gt;, if &lt;code&gt;args&lt;/code&gt; is the list &lt;code&gt;(1 2 3)&lt;/code&gt;, then its elements &lt;code&gt;1 2 3&lt;/code&gt; will be inserted &lt;em&gt;without the enclosing parentheses&lt;/em&gt;. The same would apply to a term &lt;code&gt;,@code&lt;/code&gt; where &lt;code&gt;code&lt;/code&gt; is &lt;code&gt;(+)&lt;/code&gt;, only the &lt;code&gt;+&lt;/code&gt; operator would be inserted. This allows us to rewrite the &lt;code&gt;pass-args&lt;/code&gt; macro without the &lt;code&gt;append&lt;/code&gt; function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;defmacro&lt;/span&gt; &lt;span class="nv"&gt;pass-args&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;code&lt;/span&gt; &lt;span class="k"&gt;&amp;amp;rest&lt;/span&gt; &lt;span class="nv"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;,@&lt;/span&gt;&lt;span class="nv"&gt;code&lt;/span&gt; &lt;span class="o"&gt;,@&lt;/span&gt;&lt;span class="nv"&gt;args&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="nb"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;pass-args&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="mi"&gt;6&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here too we get the expected result, but something different happened under the hood: a process known as &lt;em&gt;macro expansion&lt;/em&gt;, which turns the template &lt;code&gt;(,@code ,@args)&lt;/code&gt; into actual code by inserting the required argument expressions. We can visualize the result of this process by applying the &lt;code&gt;macroexpand&lt;/code&gt; function to a quoted expression containing the macro call that we want to expand:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="nb"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;macroexpand&lt;/span&gt; &lt;span class="o"&gt;'&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;pass-args&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;T&lt;/span&gt;

&lt;span class="nb"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;macroexpand&lt;/span&gt; &lt;span class="o"&gt;'&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;pass-args&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;T&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is extremely useful when designing macros, since it allows us to see what code will be generated when passing specific arguments to a macro call. Notice that both expansions generate the same expression &lt;code&gt;(+ 1 2 3)&lt;/code&gt;, even though the former passes the &lt;code&gt;1 2 3&lt;/code&gt; arguments to the &lt;code&gt;(+)&lt;/code&gt; program, while the latter passes the &lt;code&gt;2 3&lt;/code&gt; arguments to the &lt;code&gt;(+ 1)&lt;/code&gt; program. Therefore, both macro calls will ultimately evaluate to &lt;code&gt;6&lt;/code&gt; as expected.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hello, World!
&lt;/h3&gt;

&lt;p&gt;Now let's use the &lt;code&gt;pass-args&lt;/code&gt; macro and the &lt;code&gt;format&lt;/code&gt; function to finally write a "Hello, World!" of Lisp macros:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="nb"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;macroexpand&lt;/span&gt; &lt;span class="o"&gt;'&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;pass-args&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;format&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="no"&gt;t&lt;/span&gt; &lt;span class="s"&gt;"Hello, World!"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;FORMAT&lt;/span&gt; &lt;span class="nv"&gt;T&lt;/span&gt; &lt;span class="s"&gt;"Hello, World!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;T&lt;/span&gt;

&lt;span class="nb"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;pass-args&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;format&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="no"&gt;t&lt;/span&gt; &lt;span class="s"&gt;"Hello, World!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;Hello,&lt;/span&gt; &lt;span class="nv"&gt;World!&lt;/span&gt;
&lt;span class="nv"&gt;NIL&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This macro call passes the arguments &lt;code&gt;t&lt;/code&gt; and &lt;code&gt;"Hello, World!"&lt;/code&gt; to the &lt;code&gt;(format)&lt;/code&gt; program, which expands to &lt;code&gt;(format t "Hello, World!")&lt;/code&gt;. Then it prints the string &lt;code&gt;Hello, World!&lt;/code&gt; and finally returns &lt;code&gt;NIL&lt;/code&gt;. Notice that the &lt;code&gt;(format)&lt;/code&gt; program is not a valid Common Lisp expression because &lt;code&gt;format&lt;/code&gt; is a two-argument function. Thus, unlike the &lt;code&gt;(+)&lt;/code&gt; program that could be executed with no arguments, trying to evaluate &lt;code&gt;(format)&lt;/code&gt; causes an error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="nb"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;format&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt;&lt;span class="nv"&gt;ERROR...&lt;/span&gt;
&lt;span class="nv"&gt;invalid&lt;/span&gt; &lt;span class="nc"&gt;number&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;arguments:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means that the &lt;code&gt;pass-args&lt;/code&gt; macro is also useful for &lt;strong&gt;modifying programs that would otherwise fail to evaluate&lt;/strong&gt;. Trying to evaluate the &lt;code&gt;(format t)&lt;/code&gt; expression would fail too, but if we pass it to the macro along with the &lt;code&gt;"Hello, World"&lt;/code&gt; argument, it will expand to the same valid expression as the &lt;code&gt;(format)&lt;/code&gt; program with the &lt;code&gt;t&lt;/code&gt; and &lt;code&gt;"Hello , World"&lt;/code&gt; arguments, and thus produce the same results:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="nb"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;macroexpand&lt;/span&gt; &lt;span class="o"&gt;'&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;pass-args&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;format&lt;/span&gt; &lt;span class="no"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="s"&gt;"Hello, World!"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;FORMAT&lt;/span&gt; &lt;span class="nv"&gt;T&lt;/span&gt; &lt;span class="s"&gt;"Hello, World!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;T&lt;/span&gt;

&lt;span class="nb"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;pass-args&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;format&lt;/span&gt; &lt;span class="no"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="s"&gt;"Hello, World!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;Hello,&lt;/span&gt; &lt;span class="nv"&gt;World!&lt;/span&gt;
&lt;span class="nv"&gt;NIL&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's it! A "Hello, World!" of Lisp macros. &lt;/p&gt;

&lt;h3&gt;
  
  
  Clojure
&lt;/h3&gt;

&lt;p&gt;In Clojure, this macro looks almost identical to Common Lisp, we just have to replace &lt;code&gt;()&lt;/code&gt; for &lt;code&gt;[]&lt;/code&gt; in the list of arguments, &lt;code&gt;&amp;amp;rest&lt;/code&gt; for &lt;code&gt;&amp;amp;&lt;/code&gt; to collect the optional parameters, and &lt;code&gt;,@&lt;/code&gt; for &lt;code&gt;~@&lt;/code&gt; to splice them into the template:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight clojure"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;defmacro&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;pass-args&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;~@&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;~@&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="nb"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;macroexpand&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;'&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;pass-args&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="nb"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;pass-args&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Goodbye, reader!
&lt;/h3&gt;

&lt;p&gt;Of course there is much more to macros than just appending arguments to a list representation of a program, but when I started learning Lisp I found this thought process helpful to understand this feature of the language. Hopefully this will help other learners see the power that comes from the ability to pass code as arguments, transform it as data and finally treat it as code again. This is what makes Lisp the ultimate &lt;em&gt;programmable programming language&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://www.amazon.com/-/es/gp/product/0133708756" rel="noopener noreferrer"&gt;ANSI Common Lisp&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.paulgraham.com/avg.html" rel="noopener noreferrer"&gt;Beating the Averages&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Macros.html" rel="noopener noreferrer"&gt;GNU Emacs Manual&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>lisp</category>
      <category>clojure</category>
      <category>computerscience</category>
    </item>
  </channel>
</rss>
