如何使所有命名空间的函数在 Clojure 的 .core 命名空间中可用?
How to make functions from all namespaces available in the .core namespace in Clojure?
我有一个包含多个命名空间的库。我想是否可以在核心命名空间中使用所有命名空间中的函数。这样我就可以只要求 example.core
而不是要求 example.ns1
、example.ns2
等
这是我的核心命名空间中的内容
(ns example.core
(:require [example.options :refer :all]
[example.playback :refer :all]
[example.controlls :refer :all]
[example.stored :refer :all]
[example.db :refer :all]))
这是我试图要求它的方式
(ns test-app.core
(:require [example.core :as e])
(e/foo) ; where foo is defined in one of the namespaces required by example.core
当我尝试执行时,我得到 CompilerException java.lang.RuntimeException: No such var: e/foo
我想要的可能吗?还是我必须单独导入多个命名空间?
感谢您的宝贵时间
您可以使用库 Potemkin 中的 import-vars
来执行此操作。
我有一个包含多个命名空间的库。我想是否可以在核心命名空间中使用所有命名空间中的函数。这样我就可以只要求 example.core
而不是要求 example.ns1
、example.ns2
等
这是我的核心命名空间中的内容
(ns example.core
(:require [example.options :refer :all]
[example.playback :refer :all]
[example.controlls :refer :all]
[example.stored :refer :all]
[example.db :refer :all]))
这是我试图要求它的方式
(ns test-app.core
(:require [example.core :as e])
(e/foo) ; where foo is defined in one of the namespaces required by example.core
当我尝试执行时,我得到 CompilerException java.lang.RuntimeException: No such var: e/foo
我想要的可能吗?还是我必须单独导入多个命名空间?
感谢您的宝贵时间
您可以使用库 Potemkin 中的 import-vars
来执行此操作。