title: Destructuring forms and Compojure?
body: <p>I'd thought I'd post this as I got it to work through guesswork without a real understanding of what's going on and I thought it might be helpful if someone explained it.</p>
  
  <p>I understand how to get at an element of the :params map in a Compojure handler:</p>
  
  <pre><code>(GET "/something" [some_arg] "this is the response body")
  </code></pre>
  
  <p>or</p>
  
  <pre><code>(GET "/something" {{some_arg "some_arg"} :params} "this is the response body")
  </code></pre>
  
  <p>although I don't completely understand what the <code>{some_arg "some_arg"}</code> part is doing :(</p>
  
  <p>I also wanted to access the <code>:remote-addr</code> part of the request as well as <code>some_arg</code>. And I ended up with</p>
  
  <pre><code>(GET "/something" {{some_arg "some_arg"} :params ip :remote-addr}
      (do-something-with some_arg ip))
  </code></pre>
  
  <p>So, I get that the unquoted strings <code>some_arg</code> and <code>ip</code> are the names of variables to which I want the values bound but the map above isn't a valid Clojure map. How does it work?</p>
  
  <p>I also get that this is evaluated against the Ring request map (which is somehow supplied by the <code>defroutes</code> macro) but the expression above isn't a function or macro definition so how can it 'exist' as a valid expression in my code? Is there some sort of suspension of the normal rules for macro arguments? I've been unable to find a definition of the syntax of destructuring forms comprehensible to this non-Lisp'er.</p>