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

Reply via email to