使用和要求之间的差异
问题描述:
任何人都可以解释使用
和 require
之间的区别,无论是直接使用还是:在
和 ns
宏中使用:require
?
Can anyone explain the difference between use
and require
, both when used directly and as :use
and :require
in the ns
macro?
答
require
加载libs(尚未加载)使用做同样的加上它指它们的命名空间与 clojure.core / refer
使用:exclude
等与 clojure.core / refer
一样。两者建议在 ns
中使用,而不是直接使用。
require
loads libs (that aren't already loaded), use
does the same plus it refers to their namespaces with clojure.core/refer
(so you also get the possibility of using :exclude
etc like with clojure.core/refer
). Both are recommended for use in ns
rather than directly.