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 --~--~---------~--~----~------------~-------~--~----~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 -~----------~----~----~----~------~----~------~--~---
smime.p7s
Description: S/MIME cryptographic signature