Why not make the root binding nil? If your decorate function is supposed to handle all vars, then they have to deal with the unbound case as that's part of the contract of vars.
If it's a generic thing, then maybe make a multimethod or protocol for it. On Mon, Apr 29, 2013 at 12:17 PM, AtKaaZ <atk...@gmail.com> wrote: > I'm thinking something like (def ^:dynamic *a*) where it would make more > sense that it's unbound at first > > > On Mon, Apr 29, 2013 at 7:00 PM, Jim - FooBar(); <jimpil1...@gmail.com>wrote: > >> I 've found that whenever I get a var-unbound exception it is almost >> always my fault and my fault only...why would you do (def a) anyway? >> >> Jim >> >> >> >> On 29/04/13 16:32, AtKaaZ wrote: >> >>> 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+unsubscribe@**googlegroups.com<clojure%2bunsubscr...@googlegroups.com> >>> For more options, visit this group at >>> http://groups.google.com/**group/clojure?hl=en<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+unsubscribe@**googlegroups.com<clojure%2bunsubscr...@googlegroups.com> >>> . >>> For more options, visit >>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> >>> . >>> >>> >>> >> -- >> -- >> 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+unsubscribe@**googlegroups.com<clojure%2bunsubscr...@googlegroups.com> >> For more options, visit this group at >> http://groups.google.com/**group/clojure?hl=en<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+unsubscribe@**googlegroups.com<clojure%2bunsubscr...@googlegroups.com> >> . >> For more options, visit >> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> >> . >> >> >> > -- > -- > 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. > > > -- -- 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.