If you don't want to set the initial value to nil, set it to ::unbound or
similar. Should be very
hard to accidentally bind the same value.

Jonathan


On Mon, Apr 29, 2013 at 8:04 PM, AtKaaZ <atk...@gmail.com> wrote:

> the pain with that is that it wouldn't work inside a function where a
> would be the function parameter, ok it would work in a macro but inside a
> function... that would be interesting to see
>
>
> On Mon, Apr 29, 2013 at 9:01 PM, Sean Corfield <seancorfi...@gmail.com>wrote:
>
>> Try this:
>>
>> user=> (def a)
>> #'user/a
>> user=> (bound? (var a))
>> false
>> user=> (def a nil)
>> #'user/a
>> user=> (bound? (var a))
>> true
>>
>> Sean
>>
>> On Mon, Apr 29, 2013 at 8:32 AM, AtKaaZ <atk...@gmail.com> 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+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.
>> >
>> >
>>
>>
>>
>> --
>> Sean A Corfield -- (904) 302-SEAN
>> An Architect's View -- http://corfield.org/
>> World Singles, LLC. -- http://worldsingles.com/
>>
>> "Perfection is the enemy of the good."
>> -- Gustave Flaubert, French realist novelist (1821-1880)
>>
>> --
>> --
>> 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.
>
>
>

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