Re: do-form swallows exception?

2009-02-17 Thread linh
Thank you for the quick answers. I'm new to clojure and functional programming so this "lazy"-stuff is new to me, but it makes sense and is really cool. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group.

Re: do-form swallows exception?

2009-02-17 Thread Mike Benfield
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,

Re: do-form swallows exception?

2009-02-17 Thread Christian Vest Hansen
First, "map" returns a lazy seq. Second, "do" only returns the result of the last expression. So, the mapping you do in your "do" form is never executed because you never ask for the result. Try wrapping the mapping in "dorun" to explicitly realize the lazy seq from your mapping: (defn foo []

do-form swallows exception?

2009-02-17 Thread linh
Hi, How come the following code does not throw an exception? (defn foo [] (do (map (fn [_] (throw (RuntimeException. "fail"))) [1 2]) "no exception")) this however does throw exception: (defn foo [] (map (fn [_] (throw (RuntimeException. "fail"))) [1 2])) Is this a bug or am I miss