title: Inconsistency in Clojure: functions in macros and IllegalArgumentException
body: <p>Two following examples of using a function in a macro result in evaluations without errors.</p>
  
  <pre><code>(defmacro works []
    (let [f (fn [] 1)]
      `(~f)))
  (works)
  ;; =&gt; 1
  
  (defn my-nullary-fn []
    (fn [] 2))
  (defmacro also-works []
    (let [f (my-nullary-fn)]
      `(~f)))
  (also-works)
  ;; =&gt; 2
  </code></pre>
  
  <p>However,</p>
  
  <pre><code>(defmacro does-not-work []
    (let [f (constantly 3)]
      `(~f)))
  (does-not-work)
  </code></pre>
  
  <p>throws</p>
  
  <pre><code>java.lang.IllegalArgumentException: No matching ctor found
  for class clojure.core$constantly$fn__4051 
  </code></pre>
  
  <p>Likewise,</p>
  
  <pre><code>(defn my-unary-fn [x]
    (fn [] x))
  (defmacro also-does-not-work []
    (let [f (my-unary-fn 4)]
      `(~f)))
  (also-does-not-work)
  </code></pre>
  
  <p>throws</p>
  
  <pre><code>java.lang.IllegalArgumentException No matching ctor found
  for class user$my_other_fn$fn__12802
  </code></pre>
  
  <p>What might be the reason? Is there a difference between function objects returned by <code>fn</code>, <code>my-nullary-fn</code>, <code>constantly</code> and <code>my-unary-fn</code>?</p>
  
  <p>I'm running Clojure 1.5.1.</p>
  
  <p><a href="http://dev.clojure.org/jira/browse/CLJ-946">CLJ-946</a> might be related.</p>