On Feb 21, 4:52 am, David Jagoe <davidja...@gmail.com> wrote:
> Is it considered unusual to pass a var into a function? My use-case is
> as follows: I want code to be able to register a function on a hook
> (kinda like emacs). Each of the registered functions should be called
> once on a particular well-defined event. I want the process of
> registering a particular function to be idempotent (i.e. if someone
> adds the same function twice it is only registered and called once).

What you're describing sounds reasonable, but I've actually already
implemented that in my own library:

https://github.com/technomancy/robert-hooke

I think that should cover what you're looking for. The basic add-hook
usage is a bit more complicated than your example since the hook
function has control over the target function's arguments and return
value as well and can prevent the target function (or rather:
continuation) from being called, but there are also append and prepend
macros available if you are only interested in adding side effects.

-Phil

-- 
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