Hi ppl,
Above I wrote a macro with-open-flexi! ... which I'm planning to use
in my app's API . .. please let me know if there are any bugs /
gotchas / improvements etc...
I didn't get any responses, so does it means there is something so
obviously wrong that you can't even begin where to start :) (I doubt
so) or does it looks OK ..?
(See the above post for detailed comments & usage)
(defmacro with-open-flexi!
[bindings & body]
(if (= 0 (count bindings))
`(do ~...@body)
(let [[o i c & more] bindings]
`(let [~o ~i]
(try
(with-open-flexi! [...@more] ~...@body)
(finally ~c))))))
- Thanks
On Apr 24, 4:07 am, ataggart <[email protected]> wrote:
> I wrote this, which seems to solve the problem being discussed:
>
> http://gist.github.com/377278
>
> Thoughts?
>
> On Apr 23, 8:10 am, Armando Blancas <[email protected]> wrote:
>
>
>
> > > Is there any easy workaround which doesn't involve defing a global
> > > conn.
>
> > To do all in a single place you'll have to mimic the Java idiom.
>
> > (let [conn (atom nil)]
> > (try
> > (reset! conn (API/getConnection ...) ...
> > (catch ...)
> > (finally(if @conn (API/closeConnection @conn)))))
>
> > As it's been explained, a better way would be a variant of with-open,
> > maybe within atryform if you want to handle open errors locally.
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to [email protected]
> > Note that posts from new members are moderated - please be patient with
> > your first post.
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group
> > athttp://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 [email protected]
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group
> athttp://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 [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en