Skip to content

Instantly share code, notes, and snippets.

@d11wtq d11wtq/declare.clj
Last active Aug 29, 2015

What would you like to do?
Implicit forward declarations for Clojure
(defn def?
[[a b]]
(if (#{'defn 'def} a) b))
(defmacro progn
[& sexps]
(let [names (->> sexps (filter def?) (map def?))]
(declare ~@names)
(defn x
(* (y n) n))
(defn y
(* z n))
(def z 3))

This comment has been minimized.

Copy link
Owner Author

d11wtq commented May 27, 2015

I wish the Clojure compiler did this automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.