How to check if character is allowed in current namespace?

I want to check if a character is allowed in the current namespace. What is the canonical way to do this?

+3
source share
2 answers

After sifting through the API documents, once again I came across what might be a suitable 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)
+4
source

Check out this page . for example

(ns-map *ns*)

will provide you with a map of bindings in the current namespace. You can check this card to decide if your symbol is key in the card,

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

I don’t know if this is the canonical way.

+3
source

Source: https://habr.com/ru/post/1717469/


All Articles