Details
-
Type:
Enhancement
-
Status:
Closed
-
Priority:
Trivial
-
Resolution: Declined
-
Affects Version/s: Release 1.3
-
Fix Version/s: Approved Backlog
-
Component/s: None
-
Labels:None
-
Environment:Clojure 1.3, Emacs 23, OSX Lion
Description
I had a problem defining a function today, I passed :or a vector instead of a map - everything seemed to work fine but later on I got a really puzzling "Null pointer exception".
raek helped me debug the problem and suggested opening this ticket. I think it would be useful if an exception was thrown on the :or line unless it's given a map.
Here are some examples
(defn broken-example [{:keys [i processor]
:or [processor identity]}]
(processor i))
(defn working-example [{:keys [i processor]
:or {processor identity}}]
(processor i))
(working-example {:i 1})
=> 1
(broken-example {:i 1})
=> Null pointer exception
Cheers, Dave.