Question

I want to check if a symbol is resolvable in the current namespace. What's the canonical way to do this?

Was it helpful?

Solution

After sifting through the API docs once more, I've stumbled on what might be the appropriate function:

; Returns the var or Class to which the symbol
; will be resolved in the current namespace, else nil.
  (resolve 'foo)

; see also:
  (ns-resolve *a-namespace* 'foo)

OTHER TIPS

Take a look at this page. For example

(ns-map *ns*)

will give you a map of the bindings in the current namespace. You can examine this map to decide if your symbol is a key in the map,

(defn resolvable? [sym] 
  (contains? (ns-map *ns*) sym))

I do not know if this is the canonical way.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top