Monday, July 16, 2012

Dynamic bindings vs. laziness in Clojure

Now here's a thing that cost me quite a while to figure out: dynamic variables easily get in your way when accessed from lazy expressions. What happened to me is that a lazy expression using a dynamic var wouldn't remember the value of the dynamic var after leaving its binding form before the lazy expression was actually evaluated. It is only a slight relief that people more skilled than I have run into that problem, too. 

So I guess a bunch of things in the language are not exactly simple.