On May 11, 2011, at 4:45 PM, Ken Wesson wrote:

> On Wed, May 11, 2011 at 11:04 AM, Chas Emerick <cemer...@snowtide.com> wrote:
>> Somewhat worse from the standpoint of semantic consistency, hinting the var
>> with ^String yields good — yet confusing — results:
>> => (defn ^String foo
>>      ([])
>>      (^long [a])
>>      (^double [a b]))
>> #'user/foo
>> => #(Double. (foo 0 0))
>> #<user$eval2289$fn__2290 user$eval2289$fn__2290@69996e15>
>> => #(String. (foo))
>> #<user$eval2293$fn__2294 user$eval2293$fn__2294@220860ba>
>> And now the var metadata has a :tag, but only for the ^String hint:
>> => (meta #'foo)
>> {:arglists ([] [a] [a b]), :ns #<Namespace user>, :name foo, :line 1, :file
>> "NO_SOURCE_PATH", :tag java.lang.String}
> 
> What do you get from (map meta (:arglists (meta #'foo)))?

=> (->> #'foo
     meta
     :arglists
     (map (juxt identity meta)))
([[] nil] [[a] {:tag long}] [[a b] {:tag double}])

Beautiful.  I clearly wasn't clever enough to spelunk deeply enough into the 
metadataÎ.  Thank you, Ken.

I'd hope that the [] arity could get a :tag of java.lang.String, but that may 
be running into semantic difficulties as David is potentially pointing out 
separately.

Thanks again,

- 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

Reply via email to