On Sat, Nov 21, 2009 at 12:17 PM, Mark Engelberg <mark.engelb...@gmail.com> wrote: > Intuitively, it seems to me that what one wants is for lazy data > structures to contain bound values in some sort of closure-like thing > so rebindings after the fact don't affect the data structure, but > regular functions should retain their fully-dynamic behavior. I > haven't really thought it through, so probably this doesn't quite > work, but this kind of separation between the behavior of data > structures and functions when dealing with dynamic binding is what's > been going through my mind.
In Haskell, you might use a state-carrying monad as the 'closure-like thing'. If you squint enough, those monads look an awful lot like dynamic binding contexts. They have the variable-hiding properties of dynamic binding, but with a scope that's more amenable to lazy evaluation. The same technique ought to work in Clojure. I haven't played at all with the monad tools in clojure.contrib, but you might want to give them a try. If you're new to monads, there are quite a few Haskell tutorials; I won't try to enumerate them. ;-) This link is an overview of the Reader monad, which I think is most similar to the dynamic binding construct: http://www.haskell.org/all_about_monads/html/readermonad.html Best, Graham -- 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