summaryrefslogtreecommitdiff
path: root/src/clj
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2008-10-04 21:16:00 +0000
committerRich Hickey <richhickey@gmail.com>2008-10-04 21:16:00 +0000
commit75dcef321baeb94e4d35036fb7a7805e6350e662 (patch)
tree99addcd5ffe740059e447bdaee01e86aa01c6ca1 /src/clj
parent2394b54131cb9c7f64176b354c75a98f066ffd73 (diff)
improved error on malformed let
Diffstat (limited to 'src/clj')
-rw-r--r--src/clj/clojure/boot.clj19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/clj/clojure/boot.clj b/src/clj/clojure/boot.clj
index 30c8d68f..668e7ca7 100644
--- a/src/clj/clojure/boot.clj
+++ b/src/clj/clojure/boot.clj
@@ -784,6 +784,15 @@
"Bitwise shift right"
[x n] (. clojure.lang.Numbers shiftRight x n))
+(defn even?
+ "Returns true if n is even, throws an exception if n is not an integer"
+ [n] (zero? (bit-and n 1)))
+
+(defn odd?
+ "Returns true if n is odd, throws an exception if n is not an integer"
+ [n] (not (even? n)))
+
+
;;
(defn complement
@@ -2167,6 +2176,8 @@
the binding-forms are bound to their respective init-exprs or parts
therein."
[bindings & body]
+ (when (odd? (count bindings))
+ (throw (Exception. "Odd number of elements in let bindings")))
`(let* ~(destructure bindings) ~@body))
;redefine fn with destructuring
@@ -3347,14 +3358,6 @@
"Returns true if coll implements Reversible"
[coll] (instance? clojure.lang.Reversible coll))
-(defn even?
- "Returns true if n is even, throws an exception if n is not an integer"
- [n] (zero? (bit-and n 1)))
-
-(defn odd?
- "Returns true if n is odd, throws an exception if n is not an integer"
- [n] (not (even? n)))
-
(defn pmap
"Like map, except f is applied in parallel. Semi-lazy in that the
parallel computation stays ahead of the consumption, but doesn't