technomancy / robert-hooke

Hooke your Clojure functions!
Other
358 stars 27 forks source link

Why not just use `hooks` instead of `#'hooks`? #20

Open kindlychung opened 9 years ago

kindlychung commented 9 years ago

Why not just use hooks instead of #'hooks? It's likely that the hooks function will change dynamically.

(defmacro with-hooks-disabled [f & body]
  `(do (when-not (#'hooks (var ~f))
         (throw (Exception. (str "No hooks on " ~f))))
       (with-redefs [~f (#'original (var ~f))]
         ~@body)))