Skip to content

Instantly share code, notes, and snippets.

@jafingerhut
Created September 24, 2014 17:33
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jafingerhut/f3f350d6bc2e3956b645 to your computer and use it in GitHub Desktop.
;; TBD: What is going on here?
;; Why does (Math/abs (f2 -3)) cause a
;; reflection warning, but neither of the other variants does?
user=> (clojure-version)
"1.6.0"
user=> (set! *warn-on-reflection* true)
true
user=> (defn ^{:tag 'long} f1 [x] (inc x))
#'user/f1
user=> (Math/abs (f1 -3))
2
user=> (defn ^{:tag 'long} f2 [^long x] (inc x))
#'user/f2
user=> (Math/abs (f2 -3))
Reflection warning, NO_SOURCE_PATH:6:1 - call to static method abs on java.lang.Math can't be resolved (argument types: java.lang.Object).
2
user=> (defn ^{:tag 'long} f3 ^long [^long x] (inc x))
#'user/f3
user=> (Math/abs (f3 -3))
2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment