@calcit/procs 0.12.18 → 0.12.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/editing-history/202504160117-wasm-codegen-and-catalog-update.md +40 -0
  3. package/editing-history/202507160207-wasm-encoder-migration.md +48 -0
  4. package/editing-history/202507161633-wasm-data-structures.md +61 -0
  5. package/editing-history/202604151211-record-nth-optimization.md +44 -0
  6. package/editing-history/20260416-1936-predicate-narrowing-expansion.md +31 -0
  7. package/editing-history/202604160131-wasm-math-and-test-integration.md +28 -0
  8. package/editing-history/202604161507-wasm-data-structures-and-rfc-rename.md +27 -0
  9. package/editing-history/202604161520-wasm-bitwise-and-match.md +21 -0
  10. package/editing-history/202604161542-wasm-cross-ns-host-imports.md +38 -0
  11. package/editing-history/20260417-0026-wasm-rest-args.md +62 -0
  12. package/editing-history/202604170048-wasm-type-of.md +70 -0
  13. package/editing-history/202604170051-wasm-derived-predicates.md +34 -0
  14. package/editing-history/202604170132-monomorphize-map-filter.md +50 -0
  15. package/editing-history/202604170135-monomorphize-includes-reverse.md +31 -0
  16. package/editing-history/202604170140-fold-type-predicates.md +44 -0
  17. package/editing-history/202604170154-generic-dispatch-records-tuples.md +52 -0
  18. package/lib/calcit.procs.mjs +39 -6
  19. package/lib/package.json +4 -3
  20. package/package.json +4 -3
  21. package/rfc/02-04-runtime-traits-plan.md +613 -0
  22. package/rfc/02-14-project-modernization-roadmap.md +229 -0
  23. package/rfc/02-17-register-platform-api-rfc.md +115 -0
  24. package/rfc/02-18-language-theory-evolution-plan.md +367 -0
  25. package/rfc/02-23-optional-record-macro-plan.md +30 -0
  26. package/rfc/03-05-function-schema-dual-track-rfc.md +162 -0
  27. package/rfc/03-16-runtime-boundary-refactor-plan.md +546 -0
  28. package/rfc/03-18-query-def-tree-show-chunked-display-plan.md +301 -0
  29. package/rfc/04-13-call-arg-literal-rewrite-rfc.md +205 -0
  30. package/rfc/04-13-type-slot-mechanism-rfc.md +194 -0
  31. package/rfc/04-15-match-syntax-rfc.md +175 -0
  32. package/rfc/04-15-type-directed-optimization-catalog.md +170 -0
  33. package/rfc/04-15-wasm-compilation-feasibility.md +236 -0
  34. package/rfc/04-16-wasm-data-structures.md +192 -0
  35. package/rfc/README.md +40 -0
  36. package/ts-src/calcit.procs.mts +33 -6
@@ -0,0 +1,30 @@
1
+ # `%{}?` — 可选字段 Record 宏设计
2
+
3
+ **背景**:`struct` 初始化为 record 时,部分字段在语义上是可选的(`nil` 或缺省),类似 TypeScript 的 `{ a?: number; b?: number }`。当前 `%{}` 宏要求显式传入所有字段。
4
+
5
+ ## 计划新增
6
+
7
+ ### `%{}?`(macro)
8
+
9
+ 初始化 record 时允许省略可选字段,省略的字段默认为 `nil`。
10
+
11
+ ```cirru
12
+ ; 等价于 TypeScript: new MyRecord({ x: 1 }) 其中 y 为可选
13
+ %{}? MyRecord (:x 1)
14
+ ```
15
+
16
+ ### `&%{}?`(proc)
17
+
18
+ 在已有 record 基础上,允许有选择地更新标记为 optional 的字段,未传入的字段保持原值不变(区别于 `&%{}` 全量替换字段)。
19
+
20
+ ```cirru
21
+ ; 仅更新 x,y 保持原值
22
+ &%{}? my-record (:x 2)
23
+ ```
24
+
25
+ ## 实现要点
26
+
27
+ - 需要在 `defrecord` 的字段定义中引入 optional 标记(如 `(:x? :number)` 或 `(? :x :number)`)。
28
+ - `%{}?` 展开时跳过未提供的 optional 字段并填 `nil`。
29
+ - `&%{}?` 展开时仅替换显式提供的字段,其余字段从原 record 读取。
30
+ - 静态类型检查阶段,optional 字段对应类型应自动视为 `:: :optional <type>`。
@@ -0,0 +1,162 @@
1
+ # 函数 schema 现状说明(已按当前实现收敛)
2
+
3
+ ## 状态
4
+
5
+ 这个话题已经不再是“未来 RFC”,而是当前实现约定。
6
+
7
+ 为避免继续传播旧语法,本文件只保留**当前可直接照抄**的写法,不再保留早期过渡方案。
8
+
9
+ ## 当前结论
10
+
11
+ - 顶层 `defn` / `defmacro` 的函数签名信息,优先写在 `CodeEntry.:schema`;
12
+ - `:schema` 是普通数据,不再使用 `quote` 包裹;
13
+ - snapshot/compact 文件中的 canonical 写法是 wrapped `:: :fn` / `:: :macro`;
14
+ - 顶层函数 schema 不再推荐在 payload 里写 `:kind :fn`;
15
+ - 局部函数、匿名函数、临时闭包没有独立 `CodeEntry` 时,仍可保留 `hint-fn`;
16
+ - 历史上的 body-hint 返回值声明、异步 hint 旧写法、quoted schema 包裹写法,都不应继续作为新文档示例。
17
+
18
+ ## `CodeEntry` 当前推荐形态
19
+
20
+ ```cirru
21
+ %{} :CodeEntry
22
+ :doc |...
23
+ :code $ quote ...
24
+ :examples $ []
25
+ :schema $ :: :fn
26
+ {}
27
+ :generics $ [] 'T 'U
28
+ :args $ [] 'T :number
29
+ :rest :number
30
+ :return $ :: :tuple :ok 'U
31
+ :where $ []
32
+ :: 'Eq 'T
33
+ ```
34
+
35
+ 说明:
36
+
37
+ - `:schema` 缺失时,工具链仍可能回退到旧的 body 提示提取;
38
+ - 但**新内容不要再依赖这种回退**;
39
+ - 顶层 wrapped `:: :fn` 已经表达 kind,payload 内不再重复写 `:kind :fn`;
40
+ - `:name` 不属于 schema;
41
+ - `:rest :number` 仍表示“剩余参数元素类型为 `:number`”;
42
+ - 未填写的字段按动态语义处理。
43
+
44
+ ## 当前类型 DSL
45
+
46
+ ### 基础类型
47
+
48
+ - `:number`
49
+ - `:string`
50
+ - `:bool`
51
+ - `:dynamic`
52
+ - 泛型变量:`'T`
53
+
54
+ ### 复合类型
55
+
56
+ - 列表:`:: :list 'T`
57
+ - 集合:`:: :set 'T`
58
+ - 映射:`:: :map 'K 'V`
59
+ - 元组/变体:`:: :tuple :tag 'T`
60
+ - 函数:`:: :fn $ {} ...`
61
+
62
+ 注意:函数类型现在也统一成 hashmap payload,不再推荐旧的 positional 形式。
63
+
64
+ 正确示例:
65
+
66
+ ```cirru
67
+ :: :fn $ {}
68
+ :generics $ [] 'A 'B 'C
69
+ :args $ [] 'A 'B
70
+ :return 'C
71
+ ```
72
+
73
+ 更常见的嵌套场景:
74
+
75
+ ```cirru
76
+ :: :fn $ {}
77
+ :args $ []
78
+ :: :fn $ {}
79
+ :args $ [] 'A
80
+ :return 'B
81
+ :return 'B
82
+ ```
83
+
84
+ ## `:where` 约束
85
+
86
+ 约束统一放在 `:where`,每条约束是一条 tuple:
87
+
88
+ ```cirru
89
+ []
90
+ :: 'Eq 'T
91
+ :: 'Show 'T
92
+ :: 'Ord 'U
93
+ ```
94
+
95
+ 约定:
96
+
97
+ - 同一变量多条约束表示“且”;
98
+ - 顺序不影响语义;
99
+ - 若当前没有约束,直接写 `:where $ []`。
100
+
101
+ ## parse 校验示例
102
+
103
+ 文档里保留的 schema 示例应至少能被 `cr` 解析。
104
+
105
+ 主示例:
106
+
107
+ ```bash
108
+ cr demos/compact.cirru cirru parse-edn "(:: :fn ({} (:generics ([] 'T 'U)) (:args ([] 'T :number)) (:rest :number) (:return (:: :tuple :ok 'U)) (:where ([] (:: 'Eq 'T)))))"
109
+ ```
110
+
111
+ 运行时数据验证:
112
+
113
+ ```bash
114
+ cr demos/compact.cirru eval "let ((schema (:: :fn ({} (:generics ([] 'T 'U)) (:args ([] 'T :number)) (:rest :number) (:return (:: :tuple :ok 'U)) (:where ([] (:: 'Eq 'T))))))) (println schema) (println (type-of schema)) , schema"
115
+ ```
116
+
117
+ ## 顶层定义与局部定义的分工
118
+
119
+ ### 顶层定义
120
+
121
+ 优先写 `:schema`:
122
+
123
+ ```cirru
124
+ %{} :CodeEntry
125
+ :code $ quote
126
+ defn %err (message)
127
+ %:: Result :err message
128
+ :examples $ []
129
+ :schema $ :: :fn
130
+ {}
131
+ :args $ [] :dynamic
132
+ :return :tuple
133
+ ```
134
+
135
+ ### 局部函数
136
+
137
+ 仍可使用 `hint-fn`,因为它们没有独立的 `CodeEntry`:
138
+
139
+ ```cirru
140
+ fn (x)
141
+ hint-fn $ {} (:return :number)
142
+ inc x
143
+ ```
144
+
145
+ ## 不再推荐保留的旧内容
146
+
147
+ 以下内容不要再出现在新文档里:
148
+
149
+ - 顶层函数继续依赖旧 body-hint 返回值声明
150
+ - 旧的异步 hint 形式
151
+ - quoted schema 包裹写法
152
+ - 顶层 schema payload 继续写 `:kind :fn`
153
+ - 旧的 positional `fn` 类型形式
154
+ - 任何把 schema 当作“未来提案”而非“当前约定”的表述
155
+
156
+ ## 文档整理原则
157
+
158
+ 后续若继续整理 drafts:
159
+
160
+ - 只保留当前代码还能直接对照的写法;
161
+ - 已经完成迁移的讨论,优先删除而不是保留过时阶段描述;
162
+ - 历史背景放在 `editing-history/`,不要继续堆在 drafts 里。