Here's a quick proof using an interface-based primitive detector:

(definterface IPrimitiveTester
  (getType [^int x])
  (getType [^long x])
  ;; other types elided
  )

(deftype PrimitiveTester []
  IPrimitiveTester
  (getType [this ^int x] :int)
  (getType [this ^long x] :long)
  ;; other types elided
  )

(defmacro primitive-type [x]
  `(.getType (PrimitiveTester.) ~x))

(comment

  user=> (primitive-type 5) ;unboxed
  :long
  user=> (primitive-type (Integer/parseInt "5")) ;unboxed
  :int
  user=> (class (Integer/parseInt "5")) ;boxed
  java.lang.Long

  )

Justin

-- 
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