After some investigation, the before-the-arglist syntax only seems useful for defining fn's that return primitive types. They don't seem to help resolve reflection calls.
(require '[clojure.tools.analyzer :refer [ast]]) ; this creates a double-emitting fn (ast (fn (^double [^double a] a))) ; => ;{:op :fn-expr, ; ... ; :methods ; ({:op :fn-method, ; ... ; :arg-types (#<Type Ljava/lang/Object;>), ; :return-type #<Type D>}), ;double return type here ; ... ; :tag nil} ; no tag ; this creates a regular old fn (ast (fn (^String [a] 1))) ; => ;{:op :fn-expr, ; ... ; ({:op :fn-method, ; ... ; :arg-types (#<Type Ljava/lang/Object;>), ; :return-type #<Type Ljava/lang/Object;>}), ;object return type ; ... ; :tag nil} ; no tag ; this creates a String-hinted fn (ast ^String (fn a [a] 1)) ;{:op :meta, ; ... ; :expr ; {:op :fn-expr, ; ... ; :methods ; ({:op :fn-method, ; :arg-types (#<Type Ljava/lang/Object;>), ; :return-type #<Type Ljava/lang/Object;>}), ; ... ; :tag String}} I don't see where before-the-arglist is useful outside of primitive fns. Thanks, Ambrose On Mon, Jun 17, 2013 at 7:59 PM, Jim - FooBar(); <jimpil1...@gmail.com>wrote: > Hi all, > > It seems to me that return type-hints can go either right after "defn", or > after the doc-string. I generally, put the return type-hints right before > the argument vector and it seems to get rid of reflection. However, I just > had a look at core.contrib.strutils2 and the author(s) put the type hint > right after 'defn' (before the var about to be defined) and again it gets > rid of reflection! Which one is it? both are acceptable? > > thanks in advance, > > Jim > > -- > -- > 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+unsubscribe@**googlegroups.com<clojure%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/**group/clojure?hl=en<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+unsubscribe@**googlegroups.com<clojure%2bunsubscr...@googlegroups.com> > . > For more options, visit > https://groups.google.com/**groups/opt_out<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.