funny you should mention that!!! that is exactly what I meant by 'my fault'...I've come to realise that dynamic scope is almost evil, thus I go to great lengths to avoid it completely...in the rare cases where I do use it I always make sure it is bound to a init/default value :)

Jim


On 29/04/13 17:17, AtKaaZ 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 <mailto: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
        <mailto: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
        <mailto:clojure%2bunsubscr...@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
        <mailto:clojure%2bunsubscr...@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
    <mailto: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
    <mailto:clojure%2bunsubscr...@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
    <mailto:clojure%2bunsubscr...@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.



--
--
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