cannot create anonymous primitive functions

Description

Primitive functions only work (e.g. return primitive types) when defined with `defn`. An equivalent function created with `fn` does not behave the same way as when created with `defn`. For example:

(definterface IPrimitiveTester
(getType

)
(getType

)
(getType

)
(getType

)
(getType

))

(deftype PrimitiveTester []
IPrimitiveTester
(getType

:int)
(getType

:long)
(getType

:float)
(getType

:double)
(getType

:object))

(defmacro pt [x]
`(.getType (PrimitiveTester.) ~x))

(defn with-defn ^double

(+ x 0.5))

(pt (with-defn 1.0)) ; => :double

(let [a (fn ^double

(+ x 0.5))]
(pt (a 0.1))) ; => :object

Please see the discussion on the mailing list for more details and thoughts on what is happening:
http://groups.google.com/group/clojure/browse_thread/thread/d83c8643a7c7d595?hl=en

Environment

None

Activity

Show:

Details

Assignee

Reporter

Labels

Priority

Affects versions

Created January 27, 2012 at 10:48 PM
Updated September 3, 2013 at 6:59 PM