On Tue, Aug 3, 2010 at 1:00 PM, Dale <dpar...@ptd.net> wrote: > On Aug 2, 11:07 pm, Mark Engelberg <mark.engelb...@gmail.com> wrote: > > Can you distill this down to the smallest possible example that > demonstrates > > the error? > > Nope. Just spent some time trying to duplicate the nested function bug > in a simpler context. > > Well if you can't duplicate the bug in a simpler context, it seems more likely that the bug is in the logic of your code, or your understanding of these constructs, doesn't it?
Your example is long enough I only had time to glance briefly at it. Based on what I could glean from that quick look, I think you may have a misunderstanding about how with-local-vars works. vars are thread-specific, and they have a lifetime that is delimted by dynamic scoping rather than lexical scoping. Using vars in conjunction with futures seems like a recipe for disaster. A null pointer exception would be not at all surprising to me in this context, because the var goes away when the block of code that created it exits. I generally advise people to stay away from vars unless they know exactly what they are doing. Vars have all sorts of unintuitive interactions with laziness and multithreading. Try refactoring your algorithm in a way that doesn't need mutable locals. If you absolutely do need a mutable local, just use an atom. -- 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