On Mon, Jul 30, 2012 at 11:05 PM, Vinay D.E <devi...@gmail.com> wrote:
> I tried putting a print and it works as expected.

Because you are realizing the whole of i to print it.

> 1) I assumed that printing out [i @a] instead of [@a i] should realize 'i'

No, [i @a] creates a two-element vector of a lazy-seq and a value (the
deref of a). Then, when the REPL prints that vector, it realizes the
lazy-seq.

> 2) If I put a breakpoint in the predicate for take-while, it gets hit ( I

Yes, it is hit while i is being realized.

> 3) This is the strangest observation of all: In the debugger I can see that
> 'a' is getting incremented, its changing when the breakpoint is hit!  but
> the baffling thing is, when the result is printed out, I still get 0 as the
> value for a.

Because the value of @a is bound before i is realized, so 0 is bound
into the vector, and then i is realized during which process you see a
being incremented.

> Isn't (print i) the same as [i @a] ?  since i is realized first, shouldn't
> @a  be correctly printed?

No, see above.

> Why is the breakpoint showing me that a is changing ?

Because it _is_ changing but _after_ the top level of the vector has
been evaluated.
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

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