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.
This commit is contained in:
parent
1481a806b7
commit
12058d2dcf
2 changed files with 30 additions and 0 deletions
|
|
@ -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).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue