Hi,

On 21 Feb., 13:52, David Jagoe <davidja...@gmail.com> wrote:

> Is that considered bad practice and if so can you think of a nicer way
> of doing it? It seems like a very weird API... Is there a way I can
> pass in the function and determine its var internally? Is there some
> alternative/better way of determining function uniqueness or will I
> always be defeated somehow (e.g. by importing a function into a new
> namespace)?

Is there a reason, not to use the function object directly?

(def hook (atom #{}))

(defn add-to-hook
  [h & fs]
  (swap! into h fs))

(defn run-hook
  [h]
  (doseq [f @h] (f)))

(defn test [] nil)

(let [test2 (fn [] nil)]
  (add-to-hook hook test test2))

(run-hook hook)

It should work even with aliased functions. However with "hot-
patching" during development you might run into trouble. But for
production systems it should be fine, no?

Sincerely
Meikel

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to