在 Clojure 中: : 用于什么?

我知道 Clojure 中的关键词是 :keyword。但是 ::是用来做什么的呢?为什么它看起来像有装订?

user=> :foo
:foo
user=> ::foo
:user/foo
10222 次浏览

The double colon is there to fully qualify keywords with your current namespace. This is intended to avoid name clashes for keywords which are meaningful for different libraries. Without fully qualified keywords you might accidentally overwrite some values in a map and break compatibility with a library.

As now documented for Clojure as well as for ClojureScript, :: keywords can also be used to resolve namespace aliases. For example, ::foo/bar will evaluate to :clojure.core/bar if foo is an alias of clojure.core. Reader exception is thrown if foo does not resolve to a namespace.