I hadn't time to read the whole post, but, I I understand it well, this snipset

(defmacro with-context [options & body]
 `(let [context# (create-context options)
        thread# (create-thread context)
        sources# (atom {})
        receivers# (atom {})]
    (binding [init-receiver (partial init-receiver-on context# receivers#)
              init-source (partial init-source-on context# sources#)
              publish (partial publish-on context# sources#)
              receiver (partial receive-on context# receivers#)]
      (try
        (do ~...@body)
        (finally
          ... close stuff, cleanup)))))

can be written more or less:

(defn with-context [options action]
   (let [context ......])
    (binding [init-receiver .....]
     (try (action) (finally ....)))

That can be called with

(with-context  options #(body))

You can then wrap this call in a macro to remove the #().

I am not sure it is a good idea, but it is always good to know for
which precise feature you need the macro.

Here tou need it to prevent to have to pass some code around as a function.
That's one frequent usage of macro, it can help readability and (very
little) performance.
But depending of the situation. you might want to trade these
advantages for composability and ease of programming.


Best,

Nicolas.

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