不使用哪些优势:refer在:require已经使用过:only的:use?以下是同义词吗?
(ns so.example (:use [my.lib :only [function]]))
Run Code Online (Sandbox Code Playgroud)
和
(ns so.example (:require [my.lib :refer [function]]))
Run Code Online (Sandbox Code Playgroud) 我是Clojure和Leiningen的新手,我已经确定我想要使用的一些内容位于clojure.contrib.generic.math-functions中.我在http://richhickey.github.com/clojure-contrib/branch-1.1.x/math-api.html找到了API的信息,但我找不到任何可以帮助我弄清楚应该放入什么的东西我的project.clj文件用于该依赖项.
我曾尝试[clojure.contrib.generic.math-functions "1.1"],[clojure.contrib.generic.math-functions "1.1.x"]和[clojure.contrib.generic.math-functions "1.1.0"].对于每一个,我得到像......
...
Caused by: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException: Missing:
----------
1) clojure.contrib.generic.math-functions:clojure.contrib.generic.math-functions:jar:1.1
Run Code Online (Sandbox Code Playgroud) 作者在《Clojure风格指南》中写道:
Prefer using :require :refer :all over :use in ns macro
Run Code Online (Sandbox Code Playgroud)
他没有给出任何解释为什么这是一个好主意。是否有充分的理由避免在ns宏中使用:use?
有没有办法在用require或加载clojure库时重命名它们use?
例如,有没有办法做某事
(require 'some.include.path.some-library :as something-else)
Run Code Online (Sandbox Code Playgroud)
然后引用some-library通过的元素something-else/element-name?
谢谢.