我一直以为 {:keys [a b c d]}
会按照 a→b→c→d
的顺序进行解构,以下内容进行了证明
haystack.core=> (clojure.pprint/pprint (destructure '[{:keys [a b c d] :as options} {}]))
[map__14131
{}
map__14131
(if
(clojure.core/seq? map__14131)
(clojure.lang.PersistentHashMap/create (clojure.core/seq map__14131))
map__14131)
options
map__14131
a
(clojure.core/get map__14131 :a)
b
(clojure.core/get map__14131 :b)
c
(clojure.core/get map__14131 :c)
d
(clojure.core/get map__14131 :d)]
nil
然而,当键向量中的元素超过 10 个时,顺序突然改变
haystack.core=> (clojure.pprint/pprint (destructure '[{:keys [a b c d e f g h i j] :as options} {}]))
[map__14137
{}
map__14137
(if
(clojure.core/seq? map__14137)
(clojure.lang.PersistentHashMap/create (clojure.core/seq map__14137))
map__14137)
options
map__14137
i
(clojure.core/get map__14137 :i)
a
(clojure.core/get map__14137 :a)
e
(clojure.core/get map__14137 :e)
c
(clojure.core/get map__14137 :c)
g
(clojure.core/get map__14137 :g)
j
(clojure.core/get map__14137 :j)
h
(clojure.core/get map__14137 :h)
b
(clojure.core/get map__14137 :b)
d
(clojure.core/get map__14137 :d)
f
(clojure.core/get map__14137 :f)]
nil
我在解构源代码中没有找到任何相关信息