Hi again,

I think, I got it.  I wrote a little helper function to print the
metadata of a form:

--8<---------------cut here---------------start------------->8---
(use 'clojure.walk)
(defn print-meta
  ([form level]
     (prewalk
      (fn [x]
        (when-let [m (meta x)]
          (println "Level" level ":" x "=>" m)
          (print-meta m (inc level)))
        x)
      form))
  ([form]
     (print-meta form 0)))
--8<---------------cut here---------------end--------------->8---

Now see what happens:

--8<---------------cut here---------------start------------->8---
user> (print-meta (macroexpand-all '(def b (fn ^foo [^bar x] ^baz x))))
Level 0 : x => {:tag bar}
Level 0 : x => {:tag baz}
(def b (fn* ([x] x)))
user> (print-meta (macroexpand-all '(defn b ^foo [^bar x] ^baz x)))
Level 0 : b => {:arglists (quote ([x]))}
Level 1 : [x] => {:tag foo}
Level 1 : x => {:tag bar}
Level 0 : x => {:tag bar}
Level 0 : x => {:tag baz}
(def b (fn* ([x] x)))
--8<---------------cut here---------------end--------------->8---

So the return type metadata is actually added to the :arglist metadata
contents, so it's actually meta-metadata.  What you seem to have to do
is to make sure the :arglists metadata is there and reflects the type
hints on the actual function:

--8<---------------cut here---------------start------------->8---
user> (def ^{:arglists '(^double [^double x])}
           with-def  (fn ^double [^double x] (+ x  0.5)))
#'user/with-def
user> (pt (with-def 1))
:double
--8<---------------cut here---------------end--------------->8---

Well, that's not really obvious.  Maybe `def' could do a better job here
and build up a correct :arglists metadata value somehow...

Bye,
Tassilo

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to