Skip to content

Instantly share code, notes, and snippets.

@jafingerhut
Created September 24, 2014 17:33
Show Gist options
  • Select an option

  • Save jafingerhut/f3f350d6bc2e3956b645 to your computer and use it in GitHub Desktop.

Select an option

Save jafingerhut/f3f350d6bc2e3956b645 to your computer and use it in GitHub Desktop.

Revisions

  1. jafingerhut created this gist Sep 24, 2014.
    22 changes: 22 additions & 0 deletions tag-vars.clj
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    ;; 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