core: Stage 2 tier 6c — dispatch-table ops + misc compile (macros/plain invokes)

prefer-method/remove-method/remove-all-methods/get-method/methods become
overlay macros over ctx-capturing *-setup fns (a multimethod's method table
lives on its VAR, so the name passes quoted — the defmulti/defmethod shape).
instance? likewise (class names don't evaluate to values); satisfies? is a
plain ctx-capturing fn (evaluated args). locking and defonce become overlay
macros — locking now also evaluates the monitor expr (the old arm skipped it
and any body form past the first); defonce keeps the existing-root check.
read-string and macroexpand-1 are ctx-capturing fns.

Removed all eleven from the evaluator special arms + special-symbol?,
host_iface special-names, and compiler uncompilable-heads. evaluator-test's
locking/instance? cases use init now (overlay macros need the full env).

Surfaced pre-existing (filed): multimethod dispatch records prefer-method
preferences on the var but never consults them in ambiguous isa dispatch.

Gate: conformance 296x3 (+11 tier-6c cases), fallback-zero 73/3, fixpoint,
self-host, sci, staged, suite 4049>=4034, all specs+unit.
This commit is contained in:
Yogthos 2026-06-10 09:51:42 -04:00
parent b49cb5c934
commit 719efc56ce
7 changed files with 193 additions and 133 deletions

View file

@ -27,6 +27,42 @@
(defmacro defmethod [mm dispatch-val & fn-tail]
`(defmethod-setup (quote ~mm) ~dispatch-val (fn ~@fn-tail)))
;; Multimethod table ops (tier 6c): a multimethod's method table lives on its
;; VAR (the value is just the dispatch closure), so these pass the name quoted
;; to ctx-capturing setups — the same shape as defmulti/defmethod above.
(defmacro prefer-method [mm dval-a dval-b]
`(prefer-method-setup (quote ~mm) ~dval-a ~dval-b))
(defmacro remove-method [mm dval]
`(remove-method-setup (quote ~mm) ~dval))
(defmacro remove-all-methods [mm]
`(remove-all-methods-setup (quote ~mm)))
(defmacro get-method [mm dval]
`(get-method-setup (quote ~mm) ~dval))
(defmacro methods [mm]
`(methods-setup (quote ~mm)))
;; instance?: class names don't evaluate to values on jolt, so the type arg is
;; passed quoted to the ctx-capturing checker; the value evaluates normally.
(defmacro instance? [t x]
`(instance-check (quote ~t) ~x))
;; Single-threaded host: evaluate the monitor expr (for its effects, matching
;; Clojure's evaluation order) and the body — no lock to take.
(defmacro locking [x & body]
`(do ~x ~@body))
;; defonce: define name only if it isn't already bound to a non-nil root;
;; returns the existing var untouched otherwise (matching the prior arm).
(defmacro defonce [name expr]
`(let [v# (resolve (quote ~name))]
(if (and v# (some? (var-get v#)))
v#
(def ~name ~expr))))
;; Single arglist (Jolt defmacro is single-arity); the optional else defaults nil
;; via rest-destructuring.
(defmacro if-not [test then & [else]]