(with-open [rdr (reader file)]
...........)
So the vector you referred to is for binding and in imperative that means
assigning rdr to function (reader file). So now it is pretty obvious that
what you need is the variable, rdr, (in side the scope) and that's why
clojure takes only the first element of the vector.I guess that's logical.

Emeka




On Tue, May 12, 2009 at 4:30 PM, Andrew Wagner <wagner.and...@gmail.com>wrote:

> I just saw this on the JavaWorld article (great article by the way: 
> http://www.javaworld.com/javaworld/jw-05-2009/jw-05-clojure.html
> ) <http://www.javaworld.com/javaworld/jw-05-2009/jw-05-clojure.html>
>
> (defmacro with-open [bindings & body]
>   `(let bindings
>     (try
>       @body
>     (finally
>       (.close (first bindings))))))
>
>
> ...really? Is there some reason it only closes the first of the bindings 
> vector? It's not at all uncommon (though i wouldn't call it common either) in 
> C# to do:
>
> using ((IMyFoo foo = GetMyDisposableFoo())
>
>        (IMyBar bar = GetMyDisposableBar())){
>
>         ...blah blah blah
>
> }
>
>
> It seems like this idiom would be easy to implement in this macro. Or am I 
> missing something?
>
>
> >
>

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