[英]What's the most idiomatic way to use the :require and :use in the ns macro
What's the most idiomatic way to use the :require
and :use
in the ns
macro? 在ns
宏中:use
:require
和:use
的最惯用的方法是什么?
(ns app.core
(:require [clojure.tools.logging :as log]
[clojure.java.io :as io]
[clojure.edn])
(:use [compojure.core]
[postal.core]
[ring.adapter.jetty]
[ring.middleware.multipart-params]))
or 要么
(ns app.core
(:require [clojure.tools.logging :as log])
(:require [clojure.java.io :as io])
(:require clojure.edn)
(:use compojure.core)
(:use postal.core)
(:use ring.adapter.jetty)
(:use ring.middleware.multipart-params))
or somehow else? 还是其他方式?
Is there any common guidelines or best practices? 是否有任何通用准则或最佳做法?
Your first example is more idiomatic. 您的第一个示例更为惯用。 However, the use of use
or :use
is discouraged, so the most idiomatic way would be this: 但是,不鼓励use
或:use
,因此最惯用的方式是:
(ns app.core
(:require [clojure.edn]
[clojure.java.io :as io]
[clojure.tools.logging :as log]
[compojure.core :refer :all]
[postal.core :refer :all]
[ring.adapter.jetty :refer :all]
[ring.middleware.multipart-params :refer :all]))
You may find it beneficial to try to follow the Clojure community style guide . 您可能会发现尝试遵循Clojure社区风格指南很有帮助 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.