oh right, you mean that I should pass the var like (decorate #'a), I didn't get that when I first read it. But suppose I'm just passing the whatever-that-is (value?) like (decorate a) do I need to use a macro inside the decorate function to check if the passed thing is an unbound var?
On Mon, Apr 29, 2013 at 7:31 PM, Gary Trakhman <[email protected]>wrote: > If you're passing the var itself, I don't see why you'd need a macro. If > you want to check the namespace for a var matching an unquoted symbol, you > could do that in a macro. > > > On Mon, Apr 29, 2013 at 12:29 PM, AtKaaZ <[email protected]> wrote: > >> Seems like a good idea to have the root binding be nil. How would you >> make it check for bound inside the function? do we need some kind of macro? >> >> >> On Mon, Apr 29, 2013 at 7:23 PM, Gary Trakhman >> <[email protected]>wrote: >> >>> 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 <[email protected]> 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(); >>>> <[email protected]>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 [email protected] >>>>>> 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%[email protected]> >>>>>> 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%[email protected]> >>>>>> . >>>>>> 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 [email protected] >>>>> 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%[email protected]> >>>>> 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%[email protected]> >>>>> . >>>>> 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 [email protected] >>>> Note that posts from new members are moderated - please be patient with >>>> your first post. >>>> To unsubscribe from this group, send email to >>>> [email protected] >>>> 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 [email protected]. >>>> 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 [email protected] >>> Note that posts from new members are moderated - please be patient with >>> your first post. >>> To unsubscribe from this group, send email to >>> [email protected] >>> 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 [email protected]. >>> 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 [email protected] >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> [email protected] >> 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 [email protected]. >> 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 [email protected] > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > [email protected] > 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 [email protected]. > 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 [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] 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 [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
