2024 年 Clojure 状态调查中表示你的看法!

欢迎!请参阅关于页面以了解更多关于这个工作方式的信息。

0
ClojureScript
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)

4 答案

0

评论者:mfikes

CLJS-3115.patch 通过 CI (/)

0

评论者:mfikes

CLJS-3115.patch 添加到补丁上(i)

0

评论者:mfikes

CLJS-3115.patch 通过金丝雀(/)

0
参考资料:https://clojure.atlassian.net/browse/CLJS-3115 (由mfikes报告)
...