On Tue, Apr 30, 2013 at 11:00 AM, Tassilo Horn <t...@gnu.org> wrote:

> Gary Trakhman <gary.trakh...@gmail.com> writes:
>
> > 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.
>
> In case you really don't have the var itself but just its value, then
> "unbound" is a value, too, and you could check for it using
>
>   (instance? clojure.lang.Var$Unbound *x*)
>   ;=> true
>
> nice one, thanks!

I was thinking just in case any of these "clojure.lang.Var$Unbound" change
in the future, maybe I'd do something like this:

=>* (def uniqsym (gensym))*
#'jme3test1.x1/uniqsym

=> *uniqsym*
G__1603

=>* (defmacro defus [] `(def ~uniqsym))*
#'jme3test1.x1/defus

=> *(defus)*
#'jme3test1.x1/G__1603

=> *(class (eval uniqsym))*
clojure.lang.Var$Unbound

=> *(def unbound-class (class (eval uniqsym)))*
#'jme3test1.x1/unbound-class

=>* unbound-class*
clojure.lang.Var$Unbound

=> *(def ^:dynamic *x*)*
#'jme3test1.x1/*x*

=>* (instance? unbound-class *x*)*
true

=>* (binding [*x* 1]
     (instance? unbound-class *x*)
     )*
false

=>* (def ^:dynamic *x* 2)*
#'jme3test1.x1/*x*
=>* (binding [*x* 1]
     (instance? unbound-class *x*)
     )*
false


instead of
>
>   (not (bound? #'*x*))
>
> Bye,
> Tassilo
>
> --
> --
> 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