Happy it helped. I should mention that I used Meikel's docs as a guide, but my code don't actually push or pop all the thread bindings every time I return a lazy seq or a fn.
It felt a little ugly to me to bind *all* the dynamic vars in the namespace when I knew there were only two I needed to care about. So, in the locations where I build lazy seqs or fns to return to the user, I "manually" close over and bind *options* and *kernel*. I'd be really interested in hearing others' views on the propriety of binding all the dynamic vars every time using bound-fn or equivalent. On 11/24/09, Mark Engelberg <mark.engelb...@gmail.com> wrote: > On Mon, Nov 23, 2009 at 11:39 PM, Garth Sheldon-Coulson <g...@mit.edu> > wrote: >> Hi Mark, >> >> In Clojuratica I make what I think is "good, clean, compelling use" of >> dynamic vars. I rewrote the code to use dynamic vars after I found that >> doing it the other way became unwieldy and inelegant. > > OK this makes sense to me. > > Your use case is actually very similar to mine (lots of interrelated > functions where it would be cleaner to have them refer to some sort of > global variable that is set prior to execution). But I got tripped up > because: > 1. I think I had more use of laziness in my code than how you describe > yours. > 2. I didn't know the push-thread-bindings/pop-thread-bindings trick > to fix the spots with laziness (I tried just forcing the lazy > sequences which killed my performance -- I really needed laziness). > 3. Even if I had known the trick, I may have had difficulty > identifying all the spots where laziness was an issue since I was > returning a complex lazy tree structure. (I probably would have > tried, though.) > > So now that you've explained your use of dynamic bindings, I can > totally imagine scenarios where it is easier to "tame the laziness" > than go back to passing all the "globals" around, especially with the > convenient bound-seq macro that Meikel posted. > > This brings up another question in my mind. What kind of impact would > it have on people's code if *all* calls to lazy-seq operated the way > that bound-seq does? Would this make things more intuitive or less > intuitive? Would this radically reduce performance? > > -- > 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 > -- Sent from my mobile device -- 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