@calcit/procs 0.12.19 → 0.12.21

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/202507161633-wasm-data-structures.md +61 -0
  3. package/editing-history/20260416-1936-predicate-narrowing-expansion.md +31 -0
  4. package/editing-history/202604161507-wasm-data-structures-and-rfc-rename.md +27 -0
  5. package/editing-history/202604161520-wasm-bitwise-and-match.md +21 -0
  6. package/editing-history/202604161542-wasm-cross-ns-host-imports.md +38 -0
  7. package/editing-history/20260417-0026-wasm-rest-args.md +62 -0
  8. package/editing-history/202604170048-wasm-type-of.md +70 -0
  9. package/editing-history/202604170051-wasm-derived-predicates.md +34 -0
  10. package/editing-history/202604170132-monomorphize-map-filter.md +50 -0
  11. package/editing-history/202604170135-monomorphize-includes-reverse.md +31 -0
  12. package/editing-history/202604170140-fold-type-predicates.md +44 -0
  13. package/editing-history/202604170154-generic-dispatch-records-tuples.md +52 -0
  14. package/editing-history/202604170520-simplify-generic-defns-via-method-dispatch.md +49 -0
  15. package/editing-history/202604172316-wasm-do-println-fixes.md +41 -0
  16. package/editing-history/202604181208-split-emit-wasm-and-bump-version.md +15 -0
  17. package/editing-history/202604181430-wasm-list-match-and-method-dispatch.md +5 -0
  18. package/lib/calcit.procs.mjs +92 -6
  19. package/lib/package.json +2 -1
  20. package/package.json +2 -1
  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 +87 -6
@@ -124,11 +124,22 @@ export let _$n_assert_traits = function (value, traitDef) {
124
124
  if (!(traitDef instanceof CalcitTrait)) {
125
125
  throw new Error(`&assert-traits expected a trait definition, but received: ${toString(traitDef, true)}`);
126
126
  }
127
- const pair = lookup_impls(value);
128
- if (pair == null) {
129
- throw new Error(`&assert-traits cannot resolve impls for: ${toString(value, true)}`);
127
+ // For records/tuples, only check instance impls (not builtin fallbacks),
128
+ // matching the Rust runtime behavior of collect_impl_records_for_value.
129
+ let impls;
130
+ if (value instanceof CalcitRecord) {
131
+ impls = value.structRef.impls ?? [];
132
+ }
133
+ else if (value instanceof CalcitTuple) {
134
+ impls = value.impls ?? [];
135
+ }
136
+ else {
137
+ const pair = lookup_impls(value);
138
+ if (pair == null) {
139
+ throw new Error(`&assert-traits cannot resolve impls for: ${toString(value, true)}`);
140
+ }
141
+ impls = pair[0];
130
142
  }
131
- const impls = pair[0];
132
143
  const missing = [];
133
144
  for (let i = 0; i < traitDef.methods.length; i++) {
134
145
  const method = traitDef.methods[i];
@@ -272,6 +283,56 @@ export function _$n_record_$o_count(x) {
272
283
  return x.fields.length;
273
284
  throw new Error(`expected a record ${x}`);
274
285
  }
286
+ export function _$n_record_$o_field_tag(x, idx) {
287
+ if (!(x instanceof CalcitRecord))
288
+ throw new Error(`&record:field-tag expected a record, got ${x}`);
289
+ const i = idx;
290
+ if (i < 0 || i >= x.fields.length)
291
+ throw new Error(`&record:field-tag index ${i} out of bounds (${x.fields.length})`);
292
+ return x.fields[i];
293
+ }
294
+ // === BufList — mutable append-only list ===
295
+ // Wrapper around a plain JS Array for O(1) push.
296
+ export class CalcitBufList {
297
+ constructor(buf) {
298
+ this.buf = buf ?? [];
299
+ }
300
+ }
301
+ export function _$n_buf_list_$o_new() {
302
+ return new CalcitBufList();
303
+ }
304
+ export function _$n_buf_list_$o_push(buf, item) {
305
+ if (!(buf instanceof CalcitBufList))
306
+ throw new Error(`&buf-list:push expected a buf-list, got ${buf}`);
307
+ buf.buf.push(item);
308
+ return buf;
309
+ }
310
+ export function _$n_buf_list_$o_concat(buf, xs) {
311
+ if (!(buf instanceof CalcitBufList))
312
+ throw new Error(`&buf-list:concat expected a buf-list, got ${buf}`);
313
+ if (xs instanceof CalcitSliceList || xs instanceof CalcitList) {
314
+ const gen = xs.items();
315
+ let next = gen.next();
316
+ while (!next.done) {
317
+ buf.buf.push(next.value);
318
+ next = gen.next();
319
+ }
320
+ }
321
+ else {
322
+ throw new Error(`&buf-list:concat expected a list, got ${xs}`);
323
+ }
324
+ return buf;
325
+ }
326
+ export function _$n_buf_list_$o_to_list(buf) {
327
+ if (!(buf instanceof CalcitBufList))
328
+ throw new Error(`&buf-list:to-list expected a buf-list, got ${buf}`);
329
+ return new CalcitSliceList([...buf.buf]);
330
+ }
331
+ export function _$n_buf_list_$o_count(buf) {
332
+ if (!(buf instanceof CalcitBufList))
333
+ throw new Error(`&buf-list:count expected a buf-list, got ${buf}`);
334
+ return buf.buf.length;
335
+ }
275
336
  export function _$n_set_$o_count(x) {
276
337
  if (x instanceof CalcitSet)
277
338
  return x.len();
@@ -1376,6 +1437,9 @@ export let nil_$q_ = (x) => {
1376
1437
  export let tag_$q_ = (x) => {
1377
1438
  return x instanceof CalcitTag;
1378
1439
  };
1440
+ export let symbol_$q_ = (x) => {
1441
+ return x instanceof CalcitSymbol;
1442
+ };
1379
1443
  export let map_$q_ = (x) => {
1380
1444
  return x instanceof CalcitSliceMap || x instanceof CalcitMap;
1381
1445
  };
@@ -1674,6 +1738,8 @@ let calcit_builtin_impls = {
1674
1738
  list: null,
1675
1739
  map: null,
1676
1740
  fn: null,
1741
+ tuple: null,
1742
+ record: null,
1677
1743
  };
1678
1744
  // need to register code from outside
1679
1745
  export let register_calcit_builtin_impls = (options) => {
@@ -1714,11 +1780,31 @@ function lookup_impls(obj) {
1714
1780
  }
1715
1781
  else if (obj instanceof CalcitRecord) {
1716
1782
  tag = obj.name.toString();
1717
- impls = obj.structRef.impls;
1783
+ let instanceImpls = obj.structRef.impls;
1784
+ let builtinRecordImpls = normalize_builtin_impls(calcit_builtin_impls.record);
1785
+ if (builtinRecordImpls && instanceImpls && instanceImpls.length > 0) {
1786
+ impls = [...builtinRecordImpls, ...instanceImpls];
1787
+ }
1788
+ else if (builtinRecordImpls) {
1789
+ impls = builtinRecordImpls;
1790
+ }
1791
+ else {
1792
+ impls = instanceImpls;
1793
+ }
1718
1794
  }
1719
1795
  else if (obj instanceof CalcitTuple) {
1720
1796
  tag = obj.tag.toString();
1721
- impls = obj.impls;
1797
+ let instanceImpls = obj.impls;
1798
+ let builtinTupleImpls = normalize_builtin_impls(calcit_builtin_impls.tuple);
1799
+ if (builtinTupleImpls && instanceImpls && instanceImpls.length > 0) {
1800
+ impls = [...builtinTupleImpls, ...instanceImpls];
1801
+ }
1802
+ else if (builtinTupleImpls) {
1803
+ impls = builtinTupleImpls;
1804
+ }
1805
+ else {
1806
+ impls = instanceImpls;
1807
+ }
1722
1808
  }
1723
1809
  else if (obj instanceof CalcitSet) {
1724
1810
  tag = "&core-set-methods";
package/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calcit/procs",
3
- "version": "0.12.19",
3
+ "version": "0.12.21",
4
4
  "main": "./lib/calcit.procs.mjs",
5
5
  "devDependencies": {
6
6
  "@types/node": "^25.0.9",
@@ -19,6 +19,7 @@
19
19
  "bench-recur-smoke": "cargo run --bin cr -- calcit/test.cirru js && node --input-type=module -e \"import { test_loop } from './js-out/test-recursion.main.mjs'; const n=3000; const t0=process.hrtime.bigint(); for(let i=0;i<n;i++) test_loop(); const dt=Number(process.hrtime.bigint()-t0)/1e6; console.log('test_loop_ms='+dt.toFixed(3));\"",
20
20
  "check-smooth": "yarn fmt-rs && yarn lint-rs && yarn test-rs && yarn check-all",
21
21
  "check-all": "yarn compile && yarn try-rs && yarn try-js && yarn try-ir && yarn try-wasm",
22
+ "try-all": "yarn check-all",
22
23
  "try-rs": "cargo run --bin cr -- calcit/test.cirru",
23
24
  "warn-dyn-method": "cargo run --bin cr -- calcit/test.cirru --warn-dyn-method",
24
25
  "try-js-brk": "cargo run --bin cr -- calcit/test.cirru js && node --inspect-brk js-out/main.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calcit/procs",
3
- "version": "0.12.19",
3
+ "version": "0.12.21",
4
4
  "main": "./lib/calcit.procs.mjs",
5
5
  "devDependencies": {
6
6
  "@types/node": "^25.0.9",
@@ -19,6 +19,7 @@
19
19
  "bench-recur-smoke": "cargo run --bin cr -- calcit/test.cirru js && node --input-type=module -e \"import { test_loop } from './js-out/test-recursion.main.mjs'; const n=3000; const t0=process.hrtime.bigint(); for(let i=0;i<n;i++) test_loop(); const dt=Number(process.hrtime.bigint()-t0)/1e6; console.log('test_loop_ms='+dt.toFixed(3));\"",
20
20
  "check-smooth": "yarn fmt-rs && yarn lint-rs && yarn test-rs && yarn check-all",
21
21
  "check-all": "yarn compile && yarn try-rs && yarn try-js && yarn try-ir && yarn try-wasm",
22
+ "try-all": "yarn check-all",
22
23
  "try-rs": "cargo run --bin cr -- calcit/test.cirru",
23
24
  "warn-dyn-method": "cargo run --bin cr -- calcit/test.cirru --warn-dyn-method",
24
25
  "try-js-brk": "cargo run --bin cr -- calcit/test.cirru js && node --inspect-brk js-out/main.mjs",