Drop the duplicate fresh-sym; clarify group-by-head vs parse-extend-impls

A post-conformance review (chiasmus) flagged fresh-sym defined byte-identically
in 00-syntax and 30-macros; 00-syntax loads first, so the second is redundant.
Also note why deftype uses group-by-head while extend-protocol uses
parse-extend-impls (the latter must treat a computed class type in head position).
No behavior change.
This commit is contained in:
Yogthos 2026-06-25 17:35:18 -04:00
parent dcfe205a61
commit d77fd22bfe
3 changed files with 558 additions and 557 deletions

View file

@ -164,9 +164,8 @@
(loop [~i 0]
(when (< ~i n#) ~@body (recur (inc ~i)))))))
;; A fresh jolt symbol inside a macro body: a bare (gensym) returns a host symbol
;; the destructurer rejects, so round-trip through str.
(defn- fresh-sym [] (symbol (str (gensym))))
;; fresh-sym (a macro-body gensym round-tripped through str) is defined in
;; 00-syntax, which loads before this tier — reuse it.
;; Lazy-safe: take only the head via first (Clojure uses (seq coll), but Jolt's
;; eager seq would realize an infinite coll like (repeat nil) and hang).
@ -264,6 +263,10 @@
;; Group a flat seq that starts with a head symbol followed by its list specs
;; into [[head spec spec ...] ...] runs. Used by extend-protocol and defrecord.
;; Group deftype/defrecord/reify body forms: a symbol/nil head starts a new
;; group, every other form appends to the current one. (extend-protocol uses
;; parse-extend-impls instead — it must treat a COMPUTED class type like
;; (Class/forName "[B"), a seq, as a head, which this would misread as a method.)
(defn- group-by-head [items]
;; nil is a valid extension head (extend-protocol P ... nil (m [x] ...)).
(reduce (fn [acc x]