Skip to content

Instantly share code, notes, and snippets.

@jafingerhut
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jafingerhut/008a283c6faac8905e9f to your computer and use it in GitHub Desktop.
Save jafingerhut/008a283c6faac8905e9f to your computer and use it in GitHub Desktop.
;; Latest tools.analyzer.jvm as of Jul 29 2015 commit.
;; Clojure 1.8.0-alpha2 behavior (and I think for many previous
;; Clojure versions)
user=> (require '[clojure.tools.analyzer.jvm :as taj])
nil
user=> (def x (taj/analyze '(defn foo [x] "Not a doc string" (* x x))))
#'user/x
user=> (select-keys x [:op :children])
{:op :def, :children [:meta :init]}
user=> (select-keys (-> x :init) [:op :children])
{:op :fn, :children [:methods]}
;; Latest tools.analyzer.jvm as of Jul 29 2015 commit.
;; Clojure 1.8.0-alpha3 behavior.
user=> (require '[clojure.tools.analyzer.jvm :as taj])
nil
user=> (def x (taj/analyze '(defn foo [x] "Not a doc string" (* x x))))
#'user/x
user=> (select-keys (-> x :init) [:op :children])
{:op :with-meta, :children [:meta :expr]}
user=> (-> x :init :meta)
{:op :const, :env {:context :ctx/expr, :locals {}, :ns user, :file "/private/var/folders/g0/cyk9nztx473420r_pz4bppgh0000gn/T/form-init3449233345829548136.clj", :column 22, :line 1}, :form {:rettag nil}, :val {:rettag nil}, :type :map, :literal? true, :o-tag clojure.lang.PersistentArrayMap, :tag clojure.lang.PersistentArrayMap}
user=> (select-keys (-> x :init :expr) [:op :children])
{:op :fn, :children [:methods]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment