Try something like: (let [x (with-meta (gen-sym) {:tag String}] (defn foo [~x] ...))
- James On 4 December 2013 19:55, dm3 <deadmo...@gmail.com> wrote: > Hello, > > I've been having a little problem when trying to generate java interop > code and avoid reflection warnings. I have to generate a bunch of > functions which delegate to java constructors, like this: > > (defn mk-a [x y z] (A. x y z)) > (defn mk-b [x y z] (B. x y z)) > > The main reason here is to be able to `apply` the functions to lists of > arguments, as java constructors cannot be applied (AFAIK, would be great if > I'm wrong - would solve a lot of my problems!). > > The problem is - java constructors are overloaded: > > A(String x, int y, int z) > A(BigDecimal x, String y, int z) > ... > > I was trying to generate such functions in my top-level form, like this: > > (doseq [[java-ctor fn-name] [['A. 'mk-a] [B'. 'mk-b]] > (eval `(defn ~fn-name [x# y# z#] > (cond (string? x#) > (~java-ctor ^String x# y# z#) > > (string? y#) > (~java-ctor x# ^String y# z#)))) > > Which still generates reflection warnings as type hints are read by the > reader and applied to the forms read by the eval, not the result of the > eval itself (please, correct me if I'm wrong here). > > I have a suspicion that the way I'm approaching the problem is wrong :) > How should I go around solving this problem? > > -- > -- > 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 > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.