On Thu, Nov 26, 2009 at 05:05:17PM -0800, David Brown wrote:
>On Thu, Nov 26, 2009 at 04:00:34PM -0800, David Brown wrote:
>
>>For now, I'll do without the with-open, since in this particular case,
>>errors are going to be fairly fatal anyway.
>
>BTW, I still haven't been able to figure out how to write this
>function without hanging onto the collection across the call to
>'write-mapping'.

Ugh, I have found a very ugly hack that works.

It seems that the compiler only nulls out locals before a call in the
tail position, even if earlier calls don't reference the value any
more.

So, I went down in my call-chain to the first function that uses the
sequence directly (in a doseq), and do something like this:

   (let [real-coll @coll]
     (swap! coll (constantly nil))
     (doseq [item real-coll] ...))

I just have to wrap the collection in an atom up where I create it,
and make sure I never keep a reference to it around.

David

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