On Tuesday, November 20, 2018 at 5:50:13 PM UTC-6, Matching Socks wrote:
>
> For those keeping score at home, the CLJ-2436 patch says, 
>
>  (defn- typeref->class
> -  [typeref classloader]
> +  ^Class [typeref classloader]
>    (if (class? typeref)
>      typeref
> -   (clojure.lang.RT/classForName (typename typeref) false classloader)))
> +    (clojure.lang.RT/classForName (typename typeref) false classloader)))
>
>
> I was wondering why the compiler required the type hint.  
>

Without the type hint the compiler assumes the return type of 
typeref->class is Object. Later code that uses that return value does Java 
interop and so it was reflecting. Adding the type hint is sufficient to 
tell the consumer what it's returning.
 

> It reminded me of something I had seen in the news recently, regarding 
> ClojureScript.  The ClojureScript changes.md lists "CLJS-1997: Outward 
> function type hint propagation".  That issue, in turn, has an informative 
> comment (Thanks, Mike Fikes!) about *Clojure*:
>
> Bronsa helpfully pointed out in Slack that outward type hint propagation 
> is avoided in Clojure because it breaks things like:
>
> (defn foo [] 1)
> (defn bar [] (String/valueOf (foo)))
> (defn foo [] "foo")
> (bar)
>
>
 

-- 
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/d/optout.

Reply via email to