On Mar 26, 7:59 pm, "Stephen C. Gilardi" <squee...@mac.com> wrote:
> On Mar 26, 2009, at 7:24 PM, mikel wrote:
>
> > How would you write bound? (or alternatively, what is the name of
> > the function that serves the same purpose)?
>
> > This hypothetical function would return true if and only if its
> > argument refers to a Var with a binding in the namespace where the
> > reference appears.
>
> A namespace maintains a mapping from unqualified symbols to Vars and/
> or Classes.
>
> You can see if there is a mapping for a symbol, my-sym, in a
> namespace, my-ns with:
>
> (contains? (ns-map my-ns) my-sym)
>
> If that returns true, you can distinguish between a Var and a Class
> with:
>
> (var? ((ns-map my-ns) my-sym))
>
> If that returns true, it's a Var. A Var may be bound or unbound. You
> can distinguish those by calling the Var's ".isBound" method.
>
> If there is a binding, it may be a root binding or a thread-local
> binding. From your spec it doesn't look like you care about that
> distinction.
>
> From these building blocks, and with that terminology in place, it
> may be possible for you to implement the function you need. Please let
> me know how you make out.
Thanks!
--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---