In Phil Hagelberg's (technomancy) gripes file he states the following about Clojure:
nil is everywhere and causes bugs that are difficult to find the source
Now Phil is a smart guy who has contributed a lot to the Clojure community, and everyone uses his stuff - so I thought this was worth pondering for a moment.
One easy way to manage nil args to a function is to throw an error:
(defn myfunc [myarg1]
(when (nil? myarg1)
(throw (Exception. "nil arg for myfunc")))
(prn "done!"))
These two extra lines per argument reek of boilerplate. Is there an idiomatic way to remove them via metadata or macros?
My question is Is there a quick way to check for nil args in a Clojure function?