This might break even without future Clojure changes. It's a really bad idea.

If you really must go with a mutable accumulator, you should use something like

(let [v (atom [])
          f (fn [obj]
              (swap! v conj obj))]
      (.search searcher (MatchAllDocsQuery.) (MyCustomCollector. f))
      @v)

I take it you're implementing a Java interface here so you can't
really make it more functional without reimplementing a sizable chunk
of a third-party library.

Another thing the above code will also do is not blow up if that
.searcher method became parallel in some future version of that
library. Instead it will work perfectly.

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

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