Skip to content

Commit a4edd04

Browse files
committed
feat(core): D-563(c) — default-data-readers + defstruct de-scope decision
Smell-audited: 2: the eager requiring-resolve-at-def shape (clj-exact Var values) NameErrors inside the bootstrap AOT (bundled-.clj loads are strict at cache_gen — the known minefield) at BOTH candidate positions, so the landed shape is call-time-resolving fn values: consumers call the values, the fn-vs-Var class is the one nuance, recorded in the D-563 row with the revisit trigger. defstruct family DE-SCOPED by decision (legacy structmaps, superseded by records since 1.2, absent from the verified corpus — consumer-triggered only). {'inst 'uuid} at core end; corpus data_readers.txt 3/3 clj-matched (keys + both reader calls round-trip #inst / uuid).
1 parent 16426ee commit a4edd04

3 files changed

Lines changed: 37 additions & 4 deletions

File tree

‎.dev/debt.yaml‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,18 @@ active:
8484
same wire-riding meta_expr (doc/arglists/line/column/file; macro
8585
docstrings survive AOT artifacts — verified round-trip).
8686
(c) **var-existence gaps mainline completion surfaced**:
87-
`default-data-readers` (needs reader fns exposed as vars) and
88-
`defstruct`/`create-struct`/`struct-map`/`accessor` (legacy
89-
structmaps — implement or record a Tier de-scope decision;
90-
`defmacro`-as-var + `definline` landed 2026-07-16).
87+
`default-data-readers` DISCHARGED 2026-07-17: the {'inst 'uuid}
88+
map lands at core end (corpus data_readers.txt 3/3); VALUES are
89+
call-time-resolving fns, not clj's reader VARS — eager
90+
requiring-resolve at def time NameErrors inside the bootstrap AOT
91+
(bundled-.clj loads are strict at cache_gen) and would cost
92+
startup; consumers call the values, so the fn-vs-Var class is the
93+
one nuance (revisit only if a real lib var?-checks them).
94+
`defstruct`/`create-struct`/`struct-map`/`accessor` DE-SCOPED
95+
2026-07-17 (decision): legacy structmaps, superseded by records
96+
since clj 1.2 and absent from the verified-projects/conformance
97+
corpus — implement only when a real consumer pulls them
98+
(`defmacro`-as-var + `definline` landed 2026-07-16).
9199
(d) temporal/host-enum compare MAGNITUDES stay sign-based —
92100
recorded in the narrowed AD-043 (converge only if a real consumer
93101
diffs on them).

‎src/lang/clj/clojure/core.clj‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,6 +2310,7 @@
23102310
[s]
23112311
(eval (read-string (str "(do " s "\n)"))))
23122312

2313+
23132314
;; `(definline name & decl)` — mainline defines an `:inline`-carrying fn (a
23142315
;; compiler hint cljw has no analogue for: no inline compilation pass), so
23152316
;; the observable surface — a callable fn Var — is exactly defn's.
@@ -2625,3 +2626,21 @@
26252626
(when-let [rmsg (ex-message root)] {:cause rmsg})
26262627
(when (seq root-trace) {:trace (vec root-trace)})
26272628
(when-let [d (ex-data root)] {:data d}))))
2629+
2630+
;; `default-data-readers` — the built-in tagged-literal readers as data (clj
2631+
;; parity: values are the reader-fn VARS). cljw's reader wires #inst/#uuid
2632+
;; natively, so this map exists for the CONSUMERS of the var (edn/reader
2633+
;; libraries walking it, user code merging *data-readers*). requiring-resolve
2634+
;; loads the two thin nses at the very END of core (clj's own ordering —
2635+
;; they depend on core vars defined above; measured: sub-ms shims).
2636+
(def default-data-readers
2637+
"Default map of data reader functions provided by Clojure. May be
2638+
overridden by binding *data-readers*."
2639+
;; Values are call-time-resolving fns, not the reader VARS clj holds:
2640+
;; resolving eagerly would require the shim nses during the bootstrap
2641+
;; AOT (a known minefield — bundled .clj loads are strict at cache_gen)
2642+
;; and cost startup. Consumers CALL the values; the fn-vs-Var class is
2643+
;; the one visible nuance (D-563c note).
2644+
{'inst (fn [form] ((requiring-resolve 'clojure.instant/read-instant-date) form))
2645+
'uuid (fn [form] ((requiring-resolve 'clojure.uuid/default-uuid-reader) form))})
2646+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
(sort (map str (keys default-data-readers)))
2+
;;=> ("inst" "uuid")
3+
((get default-data-readers (quote inst)) "2024-01-01")
4+
;;=> #inst "2024-01-01T00:00:00.000-00:00"
5+
(str ((get default-data-readers (quote uuid)) "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"))
6+
;;=> "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"

0 commit comments

Comments
 (0)