Re: with-open macro

2009-05-12 Thread Emeka
Andrew, that code caused me to have headache some minutes ago :). On Tue, May 12, 2009 at 6:43 PM, Emeka wrote: > Why? > > > On Tue, May 12, 2009 at 5:37 PM, Andrew Wagner wrote: > >> Wow. Ok, yeah, I'm glad he didn't put that version in the article :) >> >> >> On Tue, May 12, 2009 at 1:17 PM, S

Re: with-open macro

2009-05-12 Thread Andrew Wagner
Oh, it's just significantly harder to read if you don't know clojure, that's all. On Tue, May 12, 2009 at 2:43 PM, Emeka wrote: > Why? > > > On Tue, May 12, 2009 at 5:37 PM, Andrew Wagner wrote: > >> Wow. Ok, yeah, I'm glad he didn't put that version in the article :) >> >> >> On Tue, May 12, 20

Re: with-open macro

2009-05-12 Thread Emeka
Why? On Tue, May 12, 2009 at 5:37 PM, Andrew Wagner wrote: > Wow. Ok, yeah, I'm glad he didn't put that version in the article :) > > > On Tue, May 12, 2009 at 1:17 PM, Stephen C. Gilardi wrote: > >> >> On May 12, 2009, at 12:30 PM, Andrew Wagner wrote: >> >>> It seems like this idiom would be ea

Re: with-open macro

2009-05-12 Thread Andrew Wagner
Wow. Ok, yeah, I'm glad he didn't put that version in the article :) On Tue, May 12, 2009 at 1:17 PM, Stephen C. Gilardi wrote: > > On May 12, 2009, at 12:30 PM, Andrew Wagner wrote: > >> It seems like this idiom would be easy to implement in this macro. Or am I >> missing something? >> > > The c

Re: with-open macro

2009-05-12 Thread Stephen C. Gilardi
On May 12, 2009, at 12:30 PM, Andrew Wagner wrote: It seems like this idiom would be easy to implement in this macro. Or am I missing something? The current implementation of clojure.core/with-open works with multiple bindings the way you're advocating. The one in the article makes for an

Re: with-open macro

2009-05-12 Thread Meikel Brandmeyer
Hi, Am 12.05.2009 um 18:56 schrieb Andrew Wagner: Right, my question is why I can't do this: (with-open [rdr (reader file) writer (get-writer) foo (get-a-foo)] ...) In fact you can do and Clojure will close the Closables in reverse order. The information you found is outdated. Sincerely Mei

Re: with-open macro

2009-05-12 Thread Emeka
The reason is because Clojure obeys arity to the letter and spirit. So if you want to tweak the code to do that, just build you only macro to accept that arity. Emeka On Tue, May 12, 2009 at 4:56 PM, Andrew Wagner wrote: > Right, my question is why I can't do this:(with-open [rdr (reader file) >

Re: with-open macro

2009-05-12 Thread Andrew Wagner
Right, my question is why I can't do this:(with-open [rdr (reader file) writer (get-writer) foo (get-a-foo)] ...) On Tue, May 12, 2009 at 12:51 PM, Emeka wrote: > (with-open [rdr (reader file)] > ...) > So the vector you referred to is for binding and in imperative that means > assignin

Re: with-open macro

2009-05-12 Thread Emeka
(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