From e9d56422bdf3960f894d9fe52f1a916db0598e83 Mon Sep 17 00:00:00 2001 From: Yogthos Date: Wed, 24 Jun 2026 00:07:35 -0400 Subject: [PATCH] docs: cross-link the numeric specializer + op tables (jolt-nzuo) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit numeric.clj dbl-spec/lng-spec and backend_scheme.clj dbl-ops/lng-ops must agree — a spec'd op with no table entry makes emit-numeric splice a nil op string. Document the contract on both sides. Comment-only; seed re-mints byte-identical, gate green. The other two ideas in this bead were rejected after inspecting the code: - collapsing inline.clj local-escapes? onto reduce-ir-children would reintroduce the under-reporting hazard its docstring deliberately guards against (default-true is load-bearing for scalar-replacement soundness). - folding numeric recur-kinds/recur-arg-lists into one walk loses the type-env threading recur-kinds needs through :let; the parallel split is justified. --- jolt-core/jolt/backend_scheme.clj | 4 ++++ jolt-core/jolt/passes/numeric.clj | 2 ++ 2 files changed, 6 insertions(+) diff --git a/jolt-core/jolt/backend_scheme.clj b/jolt-core/jolt/backend_scheme.clj index 188e169..4f5067c 100644 --- a/jolt-core/jolt/backend_scheme.clj +++ b/jolt-core/jolt/backend_scheme.clj @@ -80,6 +80,10 @@ ;; :num-kind :double|:long when every operand is that kind; these are the Chez ;; flonum/fixnum ops it lowers to — no generic dispatch, fixnums unboxed. fl?/fx? ;; comparisons carry the question mark; fl+/fx+ don't. +;; +;; CONTRACT: every op name jolt.passes.numeric/dbl-spec (resp. lng-spec) tags must +;; have an entry here, or emit-numeric splices a nil op string into the output. Keep +;; these tables and those specializers in sync. (def ^:private dbl-ops {"+" "fl+" "-" "fl-" "*" "fl*" "/" "fl/" "min" "flmin" "max" "flmax" "<" "fl" "fl>?" "<=" "fl<=?" ">=" "fl>=?" "=" "fl=?" "==" "fl=?"}) diff --git a/jolt-core/jolt/passes/numeric.clj b/jolt-core/jolt/passes/numeric.clj index 9f6e732..0bd9033 100644 --- a/jolt-core/jolt/passes/numeric.clj +++ b/jolt-core/jolt/passes/numeric.clj @@ -28,6 +28,8 @@ ;; result kind of a double-specialized op at this name/arity, or nil if N/A. ;; arithmetic -> :double; comparison -> :bool (operands specialized, result not numeric). +;; Every op name dbl-spec / lng-spec returns non-nil for must have a Chez op in +;; jolt.backend-scheme/dbl-ops resp. lng-ops, or emit-numeric splices a nil op. (defn- dbl-spec [nm n] (cond (and (>= n 1) (contains? #{"+" "-" "*" "/" "min" "max"} nm)) :double