Hi,

I spotted a weird behaviour of 'let' (or equivalently 'defn') when
multiple expressions are used in the body of the form. When one of the
expressions, but not the last one, throws an exception, it seems to be
ignored and the final value of 'let' becomes the value of the last
expression. For example, the following program when evaluated (I'm
running Clojure 1.3) returns "wrong".

(let [f (fn [x] (if (= x 10)
                     (throw (new RuntimeException "error!"))
                     "right"))]
     (map f (list 10))
     "wrong")

To me, it is rather counterintuitive - removing the last line, causes
the exception to be thrown, which is correct. Also, replacing the
'map' with a direct call to 'f', like in

(let [f (fn [x] (if (= x 10)
                     (throw (new RuntimeException "error!"))
                     "right"))]
     (f 10)
     "wrong")

causes the exception to be thrown too.

Am I overlooking something or is this a bug?

cheers,
Marcin

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