How do you guys handle the cases when the var is unbound? I mean
specifically in the cases where you just test if the var is nil.

=> (def a)
#'clojurewerkz.titanium.graph-test/a

=> a
#<Unbound Unbound: #'clojurewerkz.titanium.graph-test/a>

=> (nil? a)
false

=> (bound? a)
ClassCastException clojure.lang.Var$Unbound cannot be cast to
clojure.lang.Var  clojure.core/bound?/fn--4837 (core.clj:4954)

=> (bound? #'a)
false

ok imagine the following sample :))

=> (defn decorate [input]
     (when (not (nil? input)) (str "prefix:" input ":suffix")))
#'clojurewerkz.titanium.graph-test/decorate

=> (decorate "1")
"prefix:1:suffix"

=> (decorate a)
"prefix:Unbound: #'clojurewerkz.titanium.graph-test/a:suffix"

so... fix?
 but more importantly does anyone need to add checks for is-the-var-bound
in their code where they checked for nil ?

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to