thanks for the reply, you are right! and in fact my real
implementation is more like this, i thought that by showing them both
as macros in the post it would be easier for people to just skim read
the post and compare them side by side. probably just confused the
issue, sorry.

the thing im really interested to know is if binding the functions the
way i have (in either example) is considered 'bad form', and if a
protocol and reify is the more idiomatic solution, or if there is
another solution to this problem.


On Tue, Sep 28, 2010 at 2:41 AM, Nicolas Oury <nicolas.o...@gmail.com> wrote:
> 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

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