我有一个使用某个命名空间的clj文件,我希望定义属于另一个命名空间的东西,所以我这样做:
(def other.namespace/name-of-something "value")
Run Code Online (Sandbox Code Playgroud)
:但是当我这样做时,我得到了结果:
java.lang.Exception: Can't refer to qualified var that doesn't exist
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么?
Tim*_*ons 12
首先,您需要通过调用以确保命名空间存在create-ns:
(create-ns 'other.namespace)
Run Code Online (Sandbox Code Playgroud)
然后,您可以使用该intern函数向该命名空间添加定义:
(intern 'other.namespace 'name-of-something "value")
Run Code Online (Sandbox Code Playgroud)
你可以通过电话确认这是否存在(ns-interns 'other.namespace).
| 归档时间: |
|
| 查看次数: |
2102 次 |
| 最近记录: |