How can I get the Clojurescript namespace I am in from within a clojurescript program?

后端 未结 4 768
长发绾君心
长发绾君心 2021-01-12 08:16

How can I get the Clojurescript namespace I am in from within a clojurescript program? I want to do this do provide certain debug information (it only needs to work in dev m

4条回答
  •  天命终不由人
    2021-01-12 08:43

    During macro-expansion you can access &env and retrieve namespace information from the :ns key like this:

    (:ns &env)
    (:name (:ns &env))
    

    This only works at macro-expansion/compile time and not at runtime.

提交回复
热议问题