Clojure 1.13 增加了对检查键的支持。
Clojure 1.13 adds support for checked keys

原始链接: https://clojure.org/news/2026/07/02/clojure-1-13-alpha1

现在,您可以在 map 解构时使用新的 :keys/:syms/:strs 指令的检查变体(:keys!/:syms!/:strs!)来确保必须存在的键被绑定,如果键不存在,则会抛出异常。此外,在所有指令中,您都可以在 & 之后指定不需要绑定的键,用于文档记录或检查目的。 CLJ-2961 检查键 CLJ-2960 检查键的规范 (Specs) CLJ-2949 req! - get 的变体,在键未找到时进行报告 CLJ-2954 let/loop/let* - 禁止将 & 用作局部绑定

``` Hacker News 最新 | 过往 | 评论 | 提问 | 展示 | 招聘 | 投稿登录 Clojure 1.13 增加了对检查键(checked keys)的支持 (clojure.org) 62 分 由 FelipeCortez 发布于 2 小时前 | 隐藏 | 过往 | 收藏 | 讨论 帮助 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索: ```
相关文章

原文

You can now ensure that required keys are bound during map destructuring by using the new checked variants of the :keys/:syms/:strs directives - :keys!/:syms!/:strs!, which will throw if the key is not present. You can also, in all directives, specify keys after & which will not be bound, for documentation or checking purposes.

  • CLJ-2961 Checked keys

  • CLJ-2960 Specs for checked keys

  • CLJ-2949 req! - Variant of get that reports on key not found

  • CLJ-2954 let/loop/let* - disallow & as local binding

联系我们 contact @ memedata.com