Map is lazy. You are presumably executing (foo) at the REPL. In the
first foo, since the value calculated by map is unused, no elements of
the seq are calculated and your anonymous function never runs. In the
second foo, since the function actually returns the value and the REPL
wants to print it, the values are calculated, and your anonymous
function runs.
(defn foo2 []
(doseq [a [1 2]]
(throw (RuntimeException. "fail")))
"end")
This function always throws, because doseq always goes through the
whole seq.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---