On Sun, Oct 25, 2009 at 2:50 PM, Radford Smith <radscr...@gmail.com> wrote:

>
> Ruby blocks are anonymous functions with syntax sugar. You could write
> James' with_open method like this:
>
> def with_open(stream, &f)
>  f.call(stream)
> end
>
> The equivalent in Clojure is effectively the same:
>
> (defn with-open [stream f]
>  (f stream))


What about exception safety? Shouldn't that really be

(defn with-open [stream f]
  (try
    (f stream)
    (finally
      (.close stream))))

?

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