Created
September 3, 2019 16:17
-
-
Save darkleaf/327ccf2a14ea9ae9ff1a6ff1bfed2ebb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns foo | |
(:import | |
[clojure.lang Compiler Compiler$C])) | |
(defn get-closure-names* [form env] | |
(let [ex (with-bindings {Compiler/LOCAL_ENV env} | |
(Compiler/analyze Compiler$C/EXPRESSION form)) | |
closes (.closes ex)] | |
(->> closes | |
(keys) ;; у них ключи и значения совпадают | |
(map #(.-sym %))))) | |
(defmacro get-closure-names [form] | |
`(quote ~(get-closure-names* form &env))) | |
(let [a 1 | |
b 2] | |
(get-closure-names (fn [x] [a]))) ;;=> '(a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment