title: Unquote-splice and wrap in vector in a clojure macro
body: <p>I have recently started learning clojure and am reading <em>The Joy of Clojure</em> to get to grips with it. I have a question regarding a code segment in the <em>Macros</em> chapter (8), on page 166</p>
  
  <pre><code>(defmacro domain [name &amp; body]
    `{:tag :domain,                      ;`
      :attrs {:name (str '~name)},       ;'
      :content [~@body]})
  </code></pre>
  
  <p>As I understand it, <code>body</code> is a sequence like structure with all arguments except the first one. If so, in the third line, why are we unquote-splicing (<code>~@</code>) and putting the values in a vector again. Why not just do <code>~body</code> instead of <code>[~@body]</code>? What is the difference?</p>
  
  <p>I am sorry but I am finding it really hard to grasp the whole macros thingy (coming from python).</p>
  
  <p><strong>Edit:</strong> After a bit of experimentation, I found that this works,</p>
  
  <pre><code>(defmacro domain2 [name &amp; body]
    `{:tag :domain,                      ;`
      :attrs {:name (str '~name)},       ;'
      :content '~body})
  </code></pre>
  
  <p>and along with the results I got from Joost's answer, I think I know what is happening here. <code>body</code> is being represented as a list, and so if I don't put a <code>'</code> in front of <code>~body</code>, clojure will try to evaluate it.</p>
  
  <pre><code>user=&gt; (domain "sh" 1 2 3)
  {:content [1 2 3], :attrs {:name "sh"}, :tag :domain}
  
  user=&gt; (domain2 "sh" 1 2 3)
  {:content (1 2 3), :attrs {:name "sh"}, :tag :domain}
  </code></pre>