From 12058d2dcf018d0373cf012724493eee9ee085c8 Mon Sep 17 00:00:00 2001 From: Yogthos Date: Tue, 30 Jun 2026 10:58:44 -0400 Subject: [PATCH] Expose raw host type-test primitives under jolt.host The clojure.core type predicates bottom out at host tests that overlay Clojure can't reach. Expose them under jolt.host so the predicate web can be built as pure compositions that lower to exactly these calls: numeric tower: exact? flonum? integer-type? rational-type? collection reps: pvec? pmap? pset? cseq? empty-list? cseq-list? lazyseq? exact? is wrapped to be total (Chez's raw exact? errors on a non-number; the others return #f for a non-match). lazyseq? is exposed in lazy-bridge.ss because jolt-lazyseq? is defined there, after predicates.ss. map?/set?/seq? are deliberately not reduced to a single rep test: they are extended at runtime with sorted-collection/record/lazy arms, so only the rep predicates are exposed, not those unions. Additive only (new bindings, nothing references them yet); bench unchanged within noise. --- host/chez/lazy-bridge.ss | 5 +++++ host/chez/predicates.ss | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/host/chez/lazy-bridge.ss b/host/chez/lazy-bridge.ss index 76e0043..3e0071c 100644 --- a/host/chez/lazy-bridge.ss +++ b/host/chez/lazy-bridge.ss @@ -93,3 +93,8 @@ (def-var! "clojure.core" "make-lazy-seq" jolt-make-lazy-seq) (def-var! "clojure.core" "coll->cells" jolt-coll->cells) + +;; jolt.host/lazyseq? — raw lazy-seq rep test (the other jolt.host type-test +;; primitives are exposed in predicates.ss; this one lives here because +;; jolt-lazyseq? is defined in this file, which loads after predicates.ss). +(def-var! "jolt.host" "lazyseq?" jolt-lazyseq?) diff --git a/host/chez/predicates.ss b/host/chez/predicates.ss index 7c120fd..8b3734f 100644 --- a/host/chez/predicates.ss +++ b/host/chez/predicates.ss @@ -91,3 +91,28 @@ (def-var! "clojure.core" "boolean" jolt-boolean) (def-var! "clojure.core" "name" jolt-name) (def-var! "clojure.core" "namespace" jolt-namespace) + +;; --- jolt.host raw type-test primitives ------------------------------------- +;; The clojure.core predicates above bottom out at these host tests. Exposing them +;; under jolt.host lets overlay Clojure build the predicate web (coll?/list?/ratio? +;; …) as pure compositions that lower to exactly these calls — no perf loss. Naming: +;; integer-type?/rational-type? are the Chez TYPE tests (exact integer / exact +;; rational), distinct from clojure.core/integer? (which also gates on number?). +;; map?/set?/seq? are NOT reducible to a single rep test — they are extended at +;; runtime with sorted-collection/record/lazy arms (host-table.ss, records.ss, +;; lazy-bridge.ss) — so only the rep predicates are exposed, not those unions. +;; exact? is wrapped to be TOTAL (Chez's raw exact? errors on a non-number); the +;; rep/flonum/integer/rational tests already return #f for a non-match. +(define (jh-exact? x) (and (number? x) (exact? x))) +(def-var! "jolt.host" "exact?" jh-exact?) +(def-var! "jolt.host" "flonum?" flonum?) +(def-var! "jolt.host" "integer-type?" integer?) +(def-var! "jolt.host" "rational-type?" rational?) +(def-var! "jolt.host" "pvec?" pvec?) +(def-var! "jolt.host" "pmap?" pmap?) +(def-var! "jolt.host" "pset?" pset?) +(def-var! "jolt.host" "cseq?" cseq?) +(def-var! "jolt.host" "empty-list?" empty-list-t?) +(def-var! "jolt.host" "cseq-list?" cseq-list?) +;; jolt.host/lazyseq? is exposed in lazy-bridge.ss, where jolt-lazyseq? is defined +;; (it loads after this file, so it can't be referenced here as a value).