At first glance this is surprising to me and I'm sure I would be
tripped up by this at least a few times before I finally learned my
lesson.

On Mon, Oct 5, 2009 at 5:23 PM, MarkSwanson <mark.swanson...@gmail.com> wrote:
>
> To expand on Meikel's nice explanation:
> (to see if I understand correctly)
>
> 1. (defn baz ...)
>
> 2. (binding [foo bar] (baz [1 2 3]))  - dynamically binds foo and
> creates a lazy-seq response to the baz fn. Because map is lazy the [1
> 2 3] sequence is actually not read by anything within the binding
> dynamic scope. The binding value simply isn't used as there isn't any
> code that takes any values out of the lazy map.
>
> 3. After (binding ...) is finished it will return the last expr
> evaluated - which was (baz [1 2 3]) _and_ it puts foo back to 42.
>
> 4. The repl now wants to print (baz [1 2 3]) so it takes the values
> out of the lazy map (while foo = 42).
>
> I wonder if this concept will be thought of as a source of problems in
> the future. Or, maybe this is just one of those fundamental Clojure
> concepts you just have to learn and once you do you find you don't get
> bit by it.
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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