Make clojure.spec.alpha load and run
Four general gaps, shaken out by loading clojure.spec.alpha: - Special forms were shadowable by a same-named macro. analyze-list macroexpanded before checking special forms, so a ns that redefs def/and/or (spec excludes them via :refer-clojure :exclude) made a bare def resolve to the macro instead of the special form, breaking every defn after. Now a head in the special-form set is never macroexpanded, matching the reference macroexpand1 isSpecial check. - reify dropped all but the last arity of a multi-arity protocol method (spec reifies (specize* [s]) and (specize* [s _])). The macro keyed methods by name and overwrote; now it groups arities into one multi-arity fn. - reify instances did not implement IObj: with-meta threw and (instance? clojure.lang.IObj r) was false. Every Clojure reify carries metadata. with-meta now copies the reify to a fresh identity (shared method table) and keys its meta; instance? IObj/IMeta is true for any reify. This was the registry bug — spec's with-name returned nil for specs, so get-spec missed. - (set! (. Class field) val) was rejected. spec toggles clojure.lang.RT/checkSpecAsserts this way; the analyzer now lowers it to a jolt.host/set-static-field! call over a mutable-statics table, and a plain Class/field read consults that table. Also: .name/.getName on a Namespace and .ns/.sym on a Var (spec's ns-qualify / ->sym). analyzer + reify are seed sources (re-minted). spec.alpha now does valid?/conform/cat/keys/explain-str/check-asserts. tick.alpha.interval-test still needs time-literals data readers (separate).
This commit is contained in:
parent
f417516148
commit
7a343351d6
11 changed files with 598 additions and 532 deletions
|
|
@ -359,6 +359,23 @@
|
|||
(symbol-t-name obj)))
|
||||
((string=? method-name "equals") (and (pair? rest) (jolt=2 obj (car rest))))
|
||||
(else (error #f (string-append "No method " method-name " on Symbol")))))
|
||||
;; clojure.lang.Namespace: name/getName yield the ns name as a Symbol (JVM:
|
||||
;; Namespace.name is a Symbol). clojure.spec.alpha reads (.name *ns*).
|
||||
((jns? obj)
|
||||
(cond ((or (string=? method-name "name") (string=? method-name "getName"))
|
||||
(jolt-symbol #f (jns-name obj)))
|
||||
((string=? method-name "toString") (jns-name obj))
|
||||
(else (error #f (string-append "No method " method-name " on Namespace")))))
|
||||
;; clojure.lang.Var: ns -> its Namespace, sym -> the simple-name Symbol.
|
||||
;; clojure.spec.alpha's ->sym reads (.name (.ns v)) and (.sym v).
|
||||
((var-cell? obj)
|
||||
(cond ((string=? method-name "ns") (intern-ns! (var-cell-ns obj)))
|
||||
((or (string=? method-name "sym") (string=? method-name "name"))
|
||||
(jolt-symbol #f (var-cell-name obj)))
|
||||
((string=? method-name "getName")
|
||||
(jolt-symbol (var-cell-ns obj) (var-cell-name obj)))
|
||||
((string=? method-name "toString") (string-append "#'" (var-cell-ns obj) "/" (var-cell-name obj)))
|
||||
(else (error #f (string-append "No method " method-name " on Var")))))
|
||||
;; java.lang.Throwable interop over a Chez condition. A jolt host error
|
||||
;; (`error`/`assertion-violationf`) raises a Chez condition; Clojure code
|
||||
;; that catches it as a Throwable reads (.getMessage e) / (.toString e).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue