data.priority-map: deftype interop fixes (rseq, arity-overload, empty, Sorted)
data.priority-map's whole suite passes (4/4). It leans on deftype/collection
interop jolt got wrong; four general fixes:
- rseq dispatches to a deftype's clojure.lang.Reversible.rseq method instead of
always demanding a vector/sorted-coll (natives-seq.ss).
- a deftype method declared at two arities from two interfaces now dispatches by
arity: the priority-map has seq[this] (Seqable) and seq[this ascending]
(Sorted), so (.seq pm false) must reach the 2-arg one. find-method-any-protocol
now matches the call's arg count via procedure-arity-mask, and a deftype's own
declared method wins over the generic collection interop in dot-forms.
- (empty x) on a deftype/record with its own empty method uses it rather than
returning {} (jolt.host/jrec-method? gate in clojure.core/empty).
- clojure.lang.Sorted (comparator / entryKey / seqFrom) works on jolt's
sorted-map/set, so subseq/rsubseq run — including the priority-map delegating
.comparator to its backing sorted-map (dot-forms.ss + host-static.ss).
Listed in docs/libraries.md + the site. One re-mint (clojure.core/empty);
everything else runtime. make test green (0 new divergences), shakesmoke
byte-identical.
This commit is contained in:
parent
8a4df7b204
commit
75f6bc79d1
7 changed files with 80 additions and 5 deletions
|
|
@ -224,9 +224,14 @@
|
|||
|
||||
;; rseq: vectors + sorted colls only (Clojure), the reverse of the ascending seq.
|
||||
(define (jolt-rseq coll)
|
||||
(if (or (pvec? coll) (htable-sorted? coll))
|
||||
(list->cseq (reverse (seq->list (jolt-seq coll))))
|
||||
(jolt-throw (jolt-ex-info "rseq requires a vector or sorted collection" (jolt-hash-map)))))
|
||||
(cond
|
||||
((or (pvec? coll) (htable-sorted? coll))
|
||||
(list->cseq (reverse (seq->list (jolt-seq coll)))))
|
||||
;; a deftype/record implementing clojure.lang.Reversible (rseq) — e.g.
|
||||
;; data.priority-map — drives rseq through its own method.
|
||||
((and (jrec? coll) (find-method-any-protocol (jrec-tag coll) "rseq"))
|
||||
=> (lambda (f) (jolt-invoke f coll)))
|
||||
(else (jolt-throw (jolt-ex-info "rseq requires a vector or sorted collection" (jolt-hash-map))))))
|
||||
(def-var! "clojure.core" "rseq" jolt-rseq)
|
||||
|
||||
;; clojure.core/unchecked-* — host-defined wrapping (Java long) arithmetic from
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue