I'll take a stab at this and then someone can tell me if I'm
understanding it myself.

> (lazy-seq
>  (binding [*in* in#]
>    <-- some code -->))

This is inside the definition, so it executes whenever you actually
USE the definition--i.e. it binds *in* to in# at the time the lazy seq
is used, which is probably what you want.

> (binding [*in* in#]
>  (lazy-seq
>    <-- some code -->))

This is outside the definition, so it executes and binds *in* to in#
at the time the lazy seq is defined. In other words, the binding ends
as soon as the lazy seq is defined, so when you go to actually use the
seq, the binding has ended, and *in* has its original value.

How'd I do?

On Fri, Mar 25, 2011 at 7:47 AM, Carlos-K <cap...@gmail.com> wrote:
> Hi,
>
> Why when you create a lazy sequence, you need to do the bindings
> inside the definition?, e.g.,
>
> (lazy-seq
>  (binding [*in* in#]
>    <-- some code -->))
>
> As opposed to make the bindings first and call the lazy-seq later,
> e.g.,
>
> (binding [*in* in#]
>  (lazy-seq
>    <-- some code -->))
>
>
> Thanks
>
> --
> 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

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