In Clojure
user=> (conj {:a 1} '([:b 2] [:c 3]))
执行错误(ClassCastException)在用户/eval3(REPL:1)。
clojure.lang.PersistentVector 无法转换为 java.util.Map$Entry
但在 ClojureScript 中
cljs.user=> (conj {:a 1} '([:b 2] [:c 3]))
{:a 1, :b 2, :c 3}
有一个检查,确定条目满足 {{vector?}},但我们可以要求它们满足 {{map-entry?}}。实际上,当 {{vector?}} 不满足时给出的错误信息是:“向 map上的 conj 操作需要 _map 条目_ 或 map 条目的可序列化序列。”
Rationale: Even though this change would reject some programs, those programs are incorrect (only accidentally work), and, if ported to Clojure would fail there. Additionally, leveraging the fact that they are map entries would allow access to their keys and values, which can lead to faster code. (See leveraging map entries in CLJS-3116)