On May 12, 2011, at 2:09 AM, Ken Wesson wrote: >>>> The real problem is that first case was never actually specifying a >>>> return >>>> type - it is a type hint on the var that happened to store an fn. The fn >>>> itself can only return Object (<=1.2.0). >>> >>> ?? >>> >>> Using 1.2: >>> >>> sandbox=> (defn bar [] "foo") >>> #'sandbox/bar >>> sandbox=> (defn foo [] (.length (bar))) >>> #'sandbox/foo >>> Reflection warning, NO_SOURCE_PATH:1 - reference to field length can't >>> be resolved. >>> sandbox=> (defn ^String baz [] "foo") >>> #'sandbox/baz >>> sandbox=> (defn foo [] (.length (baz))) >>> #'sandbox/foo >>> >>> Looks like it recognizes it as hinting the return type to me. >> >> https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L3236 > > What? Please actually respond in English, rather than by pointing > mutely at something whose salience is not even apparent.
What David is getting at is that Object-based hints (as we've had all along) don't impact the signature of the generated function's invoke method -- their return types are always Object, and the hint is "just" used to determine which cast to use when the function's return is used in an interop context (and only in interop contexts, since "regular" Clojure functions never have statically-typed arguments). In contrast, primitive type hints _do_ change the signature of the corresponding function's invoke* method via the selection of the appropriate IFn$NNNNN interface that has statically-typed arguments and return types. What started this is I don't happen to think that's relevant re: syntax and the placement of the type hint — or, more to the point, that essentially no one does/will/should understand the difference in the implementation details and choices that are represented in the differentiated placement of the hint in: (defn ^String foo []) vs. (defn foo ^long []) - Chas -- 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