Hi, On Feb 24, 12:50 pm, Jules <jules.gosn...@gmail.com> wrote:
> user=> (let [arg (with-meta 's {:tag String}) arglist [arg] body (list > '.length arg)] (eval (list 'fn arglist body))) > Reflection warning, NO_SOURCE_PATH:40 - reference to field length > can't be resolved. > #<user$eval__168$fn__170 user$eval__168$fn__...@3a1834> > user=> (*1 "foo") > 3 The following seems to work for me: user=> (defn hinted-fn [name arg-types args body] (eval `(defn ~name ~(vec (map #(with-meta %1 {:tag %2}) args arg- types)) ~body))) #'user/hinted-fn user=> (hinted-fn 'len '[String] '[s] '(.length s)) #'user/len user=> (len "Hello") 5 Note, that you also have to quote the argument-types (or use the classname as a string). Using the class directly does not work: user=> (hinted-fn 'len [String] '[s] '(.length s)) Reflection warning, NO_SOURCE_PATH:7 - reference to field length can't be resolv ed. #'user/len Sincerely Meikel -- 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