Steve, thank you very much for your detailed and clear explanation.

Yes, I see many refs when I google-search for it and clues in them for
the answer. I should have done it before asking. Lazy-seqs bite lazy
bones like me.

Thanks, again.

--Kei

On Jan 24, 10:34 pm, "Stephen C. Gilardi" <squee...@mac.com> wrote:
> The map function returns a lazy sequence. Unless something forces the  
> members of the sequence to be evaluated, they won't be.
>
> In Form1, you explicitly call an anonymous function that throws.
>
> In Form2, the sequence returned by map is the last value in the "do"  
> form, so it is the value of the "do" form. You've asked the repl  
> (implicitly) to print the value returned by "do". It wants to print  
> the sequence's members so it requests the value of the first one. To  
> determine the first value, the anonymous mapped function is called and  
> throws.
>
> In Form3, map returns a value and that value is immediately thrown  
> away. Since nobody asked for the value of its "first", the value of  
> its "first" was never calculated. Form3 returns :ok because that's the  
> last value in the "do" and the repl prints :ok.
>
> A Google search for:
>
>         clojure lazy
>
> will bring up more references.
>
> --Steve
>
> On Jan 25, 2009, at 1:05 AM, Kei Suzuki wrote:
>
>
>
> > Form3 makes me puzzled. Form1 and Form2 throw exception as expected.
> > Why doesn't Form3?
>
> > Form1: (do ((fn [] (throw (Exception. "oops")))) :ok)
> > Form2: (do ((fn [] (map #(when % (throw (Exception. "oops")))
> > [true]))))
> > Form3: (do ((fn [] (map #(when % (throw (Exception. "oops")))
> > [true]))) :ok)
>
> > Thanks.
>
> > --Kei
> > >
>
>
>  smime.p7s
> 3KViewDownload

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